Merge pull-request #2044

This commit is contained in:
Frederic Guillot 2016-03-24 18:40:49 -04:00
commit 3a5f5abda2
3 changed files with 34 additions and 0 deletions

View File

@ -40,6 +40,17 @@ abstract class Base extends \Kanboard\Core\Base
return array();
}
/**
* Returns all helper classes that needs to be stored in the DI container
*
* @access public
* @return array
*/
public function getHelpers()
{
return array();
}
/**
* Listen on internal events
*

View File

@ -70,6 +70,8 @@ class Loader extends \Kanboard\Core\Base
Tool::buildDic($this->container, $instance->getClasses());
Tool::buildDICHelpers($this->container, $instance->getHelpers());
$instance->initialize();
$this->plugins[] = $instance;
}

View File

@ -55,6 +55,27 @@ class Tool
return $container;
}
/**
* Build dependency injection container for custom helpers from an array
*
* @static
* @access public
* @param Container $container
* @param array $namespaces
* @return Container
*/
public static function buildDICHelpers(Container $container, array $namespaces)
{
foreach ($namespaces as $namespace => $classes) {
foreach ($classes as $name) {
$class = '\\Kanboard\\'.$namespace.'\\'.$name;
$container['helper']->register($name, $class);
}
}
return $container;
}
/**
* Generate a jpeg thumbnail from an image
*