diff options
author | Oleg Pudeyev <oleg@bsdpower.com> | 2011-05-09 22:01:54 -0400 |
---|---|---|
committer | Oleg Pudeyev <oleg@bsdpower.com> | 2011-05-12 20:13:30 -0400 |
commit | 0ca7ad66dc8d9173394e0c5fb7e8393977de22ed (patch) | |
tree | 0693be1636c7d9893ee95443e0e26af673ecb4db /phpBB/includes/template.php | |
parent | df76885b11e56348f7fbe6274a6dbc727bb677ad (diff) | |
download | forums-0ca7ad66dc8d9173394e0c5fb7e8393977de22ed.tar forums-0ca7ad66dc8d9173394e0c5fb7e8393977de22ed.tar.gz forums-0ca7ad66dc8d9173394e0c5fb7e8393977de22ed.tar.bz2 forums-0ca7ad66dc8d9173394e0c5fb7e8393977de22ed.tar.xz forums-0ca7ad66dc8d9173394e0c5fb7e8393977de22ed.zip |
[feature/template-engine] Refactor hook logic into a separate function.
PHPBB3-9726
Diffstat (limited to 'phpBB/includes/template.php')
-rw-r--r-- | phpBB/includes/template.php | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php index c03b87b13c..9a030ffd35 100644 --- a/phpBB/includes/template.php +++ b/phpBB/includes/template.php @@ -195,14 +195,10 @@ class phpbb_template */ public function display($handle, $include_once = true) { - global $phpbb_hook; - - if (!empty($phpbb_hook) && $phpbb_hook->call_hook(array(__CLASS__, __FUNCTION__), $handle, $include_once, $this)) + $result = $this->call_hook($handle, $include_once); + if ($result !== false) { - if ($phpbb_hook->hook_return(array(__CLASS__, __FUNCTION__))) - { - return $phpbb_hook->hook_return_result(array(__CLASS__, __FUNCTION__)); - } + return $result[0]; } /* @@ -229,6 +225,27 @@ class phpbb_template } /** + * Calls hook if any is defined. + * @param string $handle Template handle being displayed. + * @param bool $include_once Allow multiple inclusions + */ + private function call_hook($handle, $include_once) + { + global $phpbb_hook; + + if (!empty($phpbb_hook) && $phpbb_hook->call_hook(array(__CLASS__, __FUNCTION__), $handle, $include_once, $this)) + { + if ($phpbb_hook->hook_return(array(__CLASS__, __FUNCTION__))) + { + $result = $phpbb_hook->hook_return_result(array(__CLASS__, __FUNCTION__)); + return array($result); + } + } + + return false; + } + + /** * Obtains language array. * This is either lang property of global $user object, or if * it is not set an empty array. |