mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[feature/template-engine] Refactor hook logic into a separate function.
PHPBB3-9726
This commit is contained in:
parent
df76885b11
commit
0ca7ad66dc
1 changed files with 24 additions and 7 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue