diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-09-13 14:07:56 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-09-13 14:07:56 -0400 |
commit | a6a00a00400f164c4b18094999a5ed72366dd519 (patch) | |
tree | 7d2bfc3fe4a36649f9092463228f4553979aef94 /app/Helper | |
parent | c405f99fc8b7420b3e69c633b3259756a1ceb2f2 (diff) |
First draft for plugins system
Diffstat (limited to 'app/Helper')
-rw-r--r-- | app/Helper/Hook.php | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/app/Helper/Hook.php b/app/Helper/Hook.php new file mode 100644 index 00000000..77756757 --- /dev/null +++ b/app/Helper/Hook.php @@ -0,0 +1,49 @@ +<?php + +namespace Helper; + +/** + * Template Hook helpers + * + * @package helper + * @author Frederic Guillot + */ +class Hook extends \Core\Base +{ + private $hooks = array(); + + /** + * Render all attached hooks + * + * @access public + * @param string $hook + * @param array $variables + * @return string + */ + public function render($hook, array $variables = array()) + { + $buffer = ''; + + foreach ($this->hooks as $name => $template) { + if ($hook === $name) { + $buffer .= $this->template->render($template, $variables); + } + } + + return $buffer; + } + + /** + * Attach a template to a hook + * + * @access public + * @param string $hook + * @param string $template + * @return \Helper\Hook + */ + public function attach($hook, $template) + { + $this->hooks[$hook] = $template; + return $this; + } +} |