diff options
| author | Frederic Guillot <fred@kanboard.net> | 2016-12-20 20:06:39 -0500 |
|---|---|---|
| committer | Frederic Guillot <fred@kanboard.net> | 2016-12-20 20:06:39 -0500 |
| commit | ae708a712a5dd932c01e734f8450b899b1407a70 (patch) | |
| tree | 348c01ad849fbeeee0fba74118b4536af4119333 /app/Core/Tool.php | |
| parent | a957195952e2c93177628ab07936d783da1388c3 (diff) | |
Offer the possibility to override internal formatter objects from plugins
Diffstat (limited to 'app/Core/Tool.php')
| -rw-r--r-- | app/Core/Tool.php | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/app/Core/Tool.php b/app/Core/Tool.php index 9b8820eb..6e457641 100644 --- a/app/Core/Tool.php +++ b/app/Core/Tool.php @@ -41,7 +41,7 @@ class Tool } /** - * Build dependency injection container from an array + * Build dependency injection containers from an array * * @static * @access public @@ -64,6 +64,29 @@ class Tool } /** + * Build dependency injection container from an array + * + * @static + * @access public + * @param Container $container + * @param array $namespaces + * @return Container + */ + public static function buildFactories(Container $container, array $namespaces) + { + foreach ($namespaces as $namespace => $classes) { + foreach ($classes as $name) { + $class = '\\Kanboard\\'.$namespace.'\\'.$name; + $container[lcfirst($name)] = $container->factory(function ($c) use ($class) { + return new $class($c); + }); + } + } + + return $container; + } + + /** * Build dependency injection container for custom helpers from an array * * @static |
