summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-08-13 18:08:46 -0400
committerFrederic Guillot <fred@kanboard.net>2016-08-13 18:08:46 -0400
commit2ebe8b32728c341ec16e1197fe2e12d32ddd5de5 (patch)
tree164455e08b993d958a7466abbb00c439b0edacbb /app
parentffe61abc6910670c5c2c243eb82d9f5851f06c6b (diff)
Add the possibility to attach template hooks with local variables
Diffstat (limited to 'app')
-rw-r--r--app/Helper/HookHelper.php25
1 files changed, 17 insertions, 8 deletions
diff --git a/app/Helper/HookHelper.php b/app/Helper/HookHelper.php
index cb4dc1ef..418c55a0 100644
--- a/app/Helper/HookHelper.php
+++ b/app/Helper/HookHelper.php
@@ -24,8 +24,8 @@ class HookHelper extends Base
{
$buffer = '';
- foreach ($this->hook->getListeners($hook) as $file) {
- $buffer .= $this->helper->asset->$type($file);
+ foreach ($this->hook->getListeners($hook) as $params) {
+ $buffer .= $this->helper->asset->$type($params['template']);
}
return $buffer;
@@ -43,8 +43,12 @@ class HookHelper extends Base
{
$buffer = '';
- foreach ($this->hook->getListeners($hook) as $template) {
- $buffer .= $this->template->render($template, $variables);
+ foreach ($this->hook->getListeners($hook) as $params) {
+ if (! empty($params['variables'])) {
+ $variables = array_merge($variables, $params['variables']);
+ }
+
+ $buffer .= $this->template->render($params['template'], $variables);
}
return $buffer;
@@ -54,13 +58,18 @@ class HookHelper extends Base
* Attach a template to a hook
*
* @access public
- * @param string $hook
- * @param string $template
+ * @param string $hook
+ * @param string $template
+ * @param array $variables
* @return $this
*/
- public function attach($hook, $template)
+ public function attach($hook, $template, array $variables = array())
{
- $this->hook->on($hook, $template);
+ $this->hook->on($hook, array(
+ 'template' => $template,
+ 'variables' => $variables,
+ ));
+
return $this;
}
}