Manage plugins from the user interface and from the command line

This commit is contained in:
Frederic Guillot
2016-05-20 12:51:05 -04:00
parent cbf896e74e
commit 8d69c49da5
20 changed files with 563 additions and 61 deletions

View File

@@ -18,16 +18,16 @@ class Loader extends \Kanboard\Core\Base
/**
* Plugin instances
*
* @access public
* @access protected
* @var array
*/
public $plugins = array();
protected $plugins = array();
/**
* Get list of loaded plugins
*
* @access public
* @return array
* @return Base[]
*/
public function getPlugins()
{
@@ -52,7 +52,7 @@ class Loader extends \Kanboard\Core\Base
if ($fileInfo->isDir() && substr($fileInfo->getFilename(), 0, 1) !== '.') {
$pluginName = $fileInfo->getFilename();
$this->loadSchema($pluginName);
$this->initializePlugin($this->loadPlugin($pluginName));
$this->initializePlugin($pluginName, $this->loadPlugin($pluginName));
}
}
}
@@ -95,9 +95,10 @@ class Loader extends \Kanboard\Core\Base
* Initialize plugin
*
* @access public
* @param Base $plugin
* @param string $pluginName
* @param Base $plugin
*/
public function initializePlugin(Base $plugin)
public function initializePlugin($pluginName, Base $plugin)
{
if (method_exists($plugin, 'onStartup')) {
$this->dispatcher->addListener('app.bootstrap', array($plugin, 'onStartup'));
@@ -107,6 +108,6 @@ class Loader extends \Kanboard\Core\Base
Tool::buildDICHelpers($this->container, $plugin->getHelpers());
$plugin->initialize();
$this->plugins[] = $plugin;
$this->plugins[$pluginName] = $plugin;
}
}