mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-16 14:41:39 +00:00
pass up to 2 parameters when calling hook
This commit is contained in:
parent
7fba6dda6d
commit
1451659ba2
|
@ -58,16 +58,36 @@ class SeedDMS_View_Common {
|
||||||
function show() {
|
function show() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Call a hook with a given name
|
||||||
|
*
|
||||||
|
* Checks if a hook with the given name and for the current view
|
||||||
|
* exists and executes it. The name of the current view is taken
|
||||||
|
* from the current class name by lower casing the first char.
|
||||||
|
* This function will execute all registered hooks in the order
|
||||||
|
* they were registered.
|
||||||
|
*
|
||||||
|
* @params string $hook name of hook
|
||||||
|
* @return mixed whatever the hook function returns
|
||||||
|
*/
|
||||||
function callHook($hook) {
|
function callHook($hook) {
|
||||||
$tmp = explode('_', get_class($this));
|
$tmp = explode('_', get_class($this));
|
||||||
if(isset($GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp[2])])) {
|
if(isset($GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp[2])])) {
|
||||||
foreach($GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp[2])] as $hookObj) {
|
foreach($GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp[2])] as $hookObj) {
|
||||||
if (method_exists($hookObj, $hook)) {
|
if (method_exists($hookObj, $hook)) {
|
||||||
|
switch(func_num_args()) {
|
||||||
|
case 1:
|
||||||
return $hookObj->$hook($this);
|
return $hookObj->$hook($this);
|
||||||
|
case 2:
|
||||||
|
return $hookObj->$hook($this, func_get_arg(1));
|
||||||
|
case 3:
|
||||||
|
default:
|
||||||
|
return $hookObj->$hook($this, func_get_arg(1), func_get_arg(2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "";
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user