From 2bda799b9ae74456a440b249022c4729d9aa6ab0 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Thu, 14 Apr 2016 22:09:48 -0400 Subject: Allow plugins loading from another location --- app/Core/Plugin/Loader.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'app/Core') diff --git a/app/Core/Plugin/Loader.php b/app/Core/Plugin/Loader.php index 775673de..0b009f75 100644 --- a/app/Core/Plugin/Loader.php +++ b/app/Core/Plugin/Loader.php @@ -2,6 +2,7 @@ namespace Kanboard\Core\Plugin; +use Composer\Autoload\ClassLoader; use DirectoryIterator; use PDOException; use LogicException; @@ -39,6 +40,10 @@ class Loader extends \Kanboard\Core\Base public function scan() { if (file_exists(PLUGINS_DIR)) { + $loader = new ClassLoader(); + $loader->addPsr4('Kanboard\Plugin\\', PLUGINS_DIR); + $loader->register(); + $dir = new DirectoryIterator(PLUGINS_DIR); foreach ($dir as $fileinfo) { @@ -69,7 +74,6 @@ class Loader extends \Kanboard\Core\Base $instance = new $class($this->container); Tool::buildDic($this->container, $instance->getClasses()); - Tool::buildDICHelpers($this->container, $instance->getHelpers()); $instance->initialize(); -- cgit v1.2.3 From 2cd06f8795e1d4e3c9c267e399e2925be8a9e5a7 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 24 Apr 2016 14:46:18 -0400 Subject: Use PLUGINS_DIR constant to load plugin templates --- app/Core/Plugin/Loader.php | 2 +- app/Core/Template.php | 2 +- tests/units/Core/TemplateTest.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'app/Core') diff --git a/app/Core/Plugin/Loader.php b/app/Core/Plugin/Loader.php index 0b009f75..799024ad 100644 --- a/app/Core/Plugin/Loader.php +++ b/app/Core/Plugin/Loader.php @@ -73,7 +73,7 @@ class Loader extends \Kanboard\Core\Base $instance = new $class($this->container); - Tool::buildDic($this->container, $instance->getClasses()); + Tool::buildDIC($this->container, $instance->getClasses()); Tool::buildDICHelpers($this->container, $instance->getHelpers()); $instance->initialize(); diff --git a/app/Core/Template.php b/app/Core/Template.php index 1874d44a..d3ec26d5 100644 --- a/app/Core/Template.php +++ b/app/Core/Template.php @@ -116,7 +116,7 @@ class Template } if ($plugin !== 'kanboard' && $plugin !== '') { - return implode(DIRECTORY_SEPARATOR, array(__DIR__, '..', '..', 'plugins', ucfirst($plugin), 'Template', $template.'.php')); + return implode(DIRECTORY_SEPARATOR, array(PLUGINS_DIR, ucfirst($plugin), 'Template', $template.'.php')); } return implode(DIRECTORY_SEPARATOR, array(__DIR__, '..', 'Template', $template.'.php')); diff --git a/tests/units/Core/TemplateTest.php b/tests/units/Core/TemplateTest.php index 9584c831..453f0b14 100644 --- a/tests/units/Core/TemplateTest.php +++ b/tests/units/Core/TemplateTest.php @@ -25,7 +25,7 @@ class TemplateTest extends Base { $template = new Template($this->container['helper']); $this->assertStringEndsWith( - implode(DIRECTORY_SEPARATOR, array('app', 'Core', '..', '..', 'plugins', 'Myplugin', 'Template', 'a', 'b.php')), + implode(DIRECTORY_SEPARATOR, array(PLUGINS_DIR, 'Myplugin', 'Template', 'a', 'b.php')), $template->getTemplateFile('myplugin:a'.DIRECTORY_SEPARATOR.'b') ); } @@ -36,7 +36,7 @@ class TemplateTest extends Base $template->setTemplateOverride('a'.DIRECTORY_SEPARATOR.'b', 'myplugin:c'); $this->assertStringEndsWith( - implode(DIRECTORY_SEPARATOR, array('app', 'Core', '..', '..', 'plugins', 'Myplugin', 'Template', 'c.php')), + implode(DIRECTORY_SEPARATOR, array(PLUGINS_DIR, 'Myplugin', 'Template', 'c.php')), $template->getTemplateFile('a'.DIRECTORY_SEPARATOR.'b') ); -- cgit v1.2.3