From 2021dccc5a444f60c5ba1673d94b39999912cd26 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 20 Sep 2015 15:53:28 -0400 Subject: Move subtask forecast to a plugin Plugin repo: https://github.com/kanboard/plugin-subtask-forecast --- app/Core/Base.php | 1 - app/Core/Plugin/Hook.php | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 app/Core/Plugin/Hook.php (limited to 'app/Core') diff --git a/app/Core/Base.php b/app/Core/Base.php index 5ed8f40a..2dec4b29 100644 --- a/app/Core/Base.php +++ b/app/Core/Base.php @@ -55,7 +55,6 @@ use Pimple\Container; * @property \Model\ProjectPermission $projectPermission * @property \Model\Subtask $subtask * @property \Model\SubtaskExport $subtaskExport - * @property \Model\SubtaskForecast $subtaskForecast * @property \Model\SubtaskTimeTracking $subtaskTimeTracking * @property \Model\Swimlane $swimlane * @property \Model\Task $task diff --git a/app/Core/Plugin/Hook.php b/app/Core/Plugin/Hook.php new file mode 100644 index 00000000..4fb55569 --- /dev/null +++ b/app/Core/Plugin/Hook.php @@ -0,0 +1,70 @@ +hooks[$hook])) { + $this->hooks[$hook] = array(); + } + + $this->hooks[$hook][] = $value; + } + + /** + * Get all bindings for a hook + * + * @access public + * @param string $hook + * @return array + */ + public function getListeners($hook) + { + return isset($this->hooks[$hook]) ? $this->hooks[$hook] : array(); + } + + /** + * Merge listener results with input array + * + * @access public + * @param string $hook + * @param array $values + * @param array $params + * @return array + */ + public function merge($hook, array &$values, array $params = array()) + { + foreach ($this->getListeners($hook) as $listener) { + $result = call_user_func_array($listener, $params); + + if (is_array($result) && ! empty($result)) { + $values = array_merge($values, $result); + } + } + + return $values; + } +} -- cgit v1.2.3