/**
* Loads the plugin file.
*
* @param object $plugin The plugin.
* @param boolean $autocreate True to autocreate.
* @param DispatcherInterface $dispatcher Optionally allows the plugin to use a different dispatcher.
*
* @return void
*
* @since 3.2
*/
protected static function import($plugin, $autocreate = true, DispatcherInterface $dispatcher = null)
{
static $plugins = [];
// Get the dispatcher's hash to allow paths to be tracked against unique dispatchers
$hash = spl_object_hash($dispatcher) . $plugin->type . $plugin->name;
if (\array_key_exists($hash, $plugins)) {
return;
}
$plugins[$hash] = true;
$plugin = Factory::getApplication()->bootPlugin($plugin->name, $plugin->type);
if ($dispatcher && $plugin instanceof DispatcherAwareInterface) {
$plugin->setDispatcher($dispatcher);
}
if (!$autocreate) {
return;
}
$plugin->registerListeners();
}