summaryrefslogtreecommitdiff
path: root/app/Core/Plugin
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-09-20 18:24:15 -0400
committerFrederic Guillot <fred@kanboard.net>2015-09-20 18:24:15 -0400
commite6f547abcfe684658a7498391db72d13b6aa7d9a (patch)
tree75b709c12fb03e11d7cb85558558f89f19abb284 /app/Core/Plugin
parent2021dccc5a444f60c5ba1673d94b39999912cd26 (diff)
Move timetable to a plugin
Plugin repository: https://github.com/kanboard/plugin-timetable
Diffstat (limited to 'app/Core/Plugin')
-rw-r--r--app/Core/Plugin/Hook.php29
-rw-r--r--app/Core/Plugin/Loader.php2
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);
}
}