diff options
Diffstat (limited to 'app/Helper')
-rw-r--r-- | app/Helper/App.php | 2 | ||||
-rw-r--r-- | app/Helper/Hook.php | 49 |
2 files changed, 51 insertions, 0 deletions
diff --git a/app/Helper/App.php b/app/Helper/App.php index e5ebefcb..5fb89afe 100644 --- a/app/Helper/App.php +++ b/app/Helper/App.php @@ -67,9 +67,11 @@ class App extends \Core\Base if (isset($this->session['flash_message'])) { $html = '<div class="alert alert-success alert-fade-out">'.$this->helper->e($this->session['flash_message']).'</div>'; unset($this->session['flash_message']); + unset($this->session['flash_error_message']); } else if (isset($this->session['flash_error_message'])) { $html = '<div class="alert alert-error">'.$this->helper->e($this->session['flash_error_message']).'</div>'; + unset($this->session['flash_message']); unset($this->session['flash_error_message']); } 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; + } +} |