diff options
Diffstat (limited to 'app/Core/Plugin')
-rw-r--r-- | app/Core/Plugin/Hook.php | 29 | ||||
-rw-r--r-- | app/Core/Plugin/Loader.php | 2 |
2 files changed, 30 insertions, 1 deletions
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 @@ -47,6 +47,18 @@ class Hook } /** + * 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 * * @access public @@ -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); } } |