[feature/template-engine] Refactor hook logic into a separate function.

PHPBB3-9726
This commit is contained in:
Oleg Pudeyev 2011-05-09 22:01:54 -04:00
parent df76885b11
commit 0ca7ad66dc

View file

@ -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];
}
/*
@ -228,6 +224,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