From e6f547abcfe684658a7498391db72d13b6aa7d9a Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 20 Sep 2015 18:24:15 -0400 Subject: Move timetable to a plugin Plugin repository: https://github.com/kanboard/plugin-timetable --- app/Core/Plugin/Hook.php | 29 +++++++++++++++++++++++++++++ app/Core/Plugin/Loader.php | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) (limited to 'app/Core/Plugin') diff --git a/app/Core/Plugin/Hook.php b/app/Core/Plugin/Hook.php index 4fb55569..fa14af13 100644 --- a/app/Core/Plugin/Hook.php +++ b/app/Core/Plugin/Hook.php @@ -46,6 +46,18 @@ class Hook return isset($this->hooks[$hook]) ? $this->hooks[$hook] : array(); } + /** + * Return true if the hook is used + * + * @access public + * @param string $hook + * @return boolean + */ + public function exists($hook) + { + return isset($this->hooks[$hook]); + } + /** * Merge listener results with input array * @@ -67,4 +79,21 @@ class Hook return $values; } + + /** + * Execute only first listener + * + * @access public + * @param string $hook + * @param array $params + * @return mixed + */ + public function first($hook, array $params = array()) + { + foreach ($this->getListeners($hook) as $listener) { + return call_user_func_array($listener, $params); + } + + return null; + } } diff --git a/app/Core/Plugin/Loader.php b/app/Core/Plugin/Loader.php index ffead9f6..45da135b 100644 --- a/app/Core/Plugin/Loader.php +++ b/app/Core/Plugin/Loader.php @@ -67,7 +67,7 @@ class Loader extends \Core\Base $filename = __DIR__.'/../../../plugins/'.$plugin.'/Schema/'.ucfirst(DB_DRIVER).'.php'; if (file_exists($filename)) { - require($filename); + require_once($filename); $this->migrateSchema($plugin); } } -- cgit v1.2.3