mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-09-08 02:50:59 +00:00
callHook merges strings and arrays returned from hook
This commit is contained in:
parent
8a7fb230da
commit
e0a12590da
|
@ -231,6 +231,7 @@ class SeedDMS_Controller_Common {
|
|||
*/
|
||||
function callHook($hook) { /* {{{ */
|
||||
$tmps = $this->getHookClassNames();
|
||||
$ret = null;
|
||||
foreach($tmps as $tmp)
|
||||
if(isset($GLOBALS['SEEDDMS_HOOKS']['controller'][lcfirst($tmp)])) {
|
||||
$this->lasthookresult = null;
|
||||
|
@ -238,29 +239,35 @@ class SeedDMS_Controller_Common {
|
|||
if (method_exists($hookObj, $hook)) {
|
||||
switch(func_num_args()) {
|
||||
case 4:
|
||||
$result = $hookObj->$hook($this, func_get_arg(1), func_get_arg(2), func_get_arg(3));
|
||||
$tmpret = $hookObj->$hook($this, func_get_arg(1), func_get_arg(2), func_get_arg(3));
|
||||
break;
|
||||
case 3:
|
||||
$result = $hookObj->$hook($this, func_get_arg(1), func_get_arg(2));
|
||||
$tmpret = $hookObj->$hook($this, func_get_arg(1), func_get_arg(2));
|
||||
break;
|
||||
case 2:
|
||||
$result = $hookObj->$hook($this, func_get_arg(1));
|
||||
$tmpret = $hookObj->$hook($this, func_get_arg(1));
|
||||
break;
|
||||
case 1:
|
||||
default:
|
||||
$result = $hookObj->$hook($this);
|
||||
$tmpret = $hookObj->$hook($this);
|
||||
}
|
||||
if($result === false) {
|
||||
return $result;
|
||||
if($tmpret === false) {
|
||||
return $tmpret;
|
||||
}
|
||||
if($result !== null) {
|
||||
$this->lasthookresult = $result;
|
||||
if($tmpret !== null) {
|
||||
$this->lasthookresult = $tmpret;
|
||||
if(is_string($tmpret)) {
|
||||
$ret = ($ret === null) ? $tmpret : (is_string($ret) ? $ret.$tmpret : array_merge($ret, array($tmpret)));
|
||||
} elseif(is_array($tmpret)) { // || is_object($tmpret)) {
|
||||
$ret = ($ret === null) ? $tmpret : (is_string($ret) ? array_merge(array($ret), $tmpret) : array_merge($ret, $tmpret));
|
||||
} else
|
||||
$ret = $tmpret;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->lasthookresult;
|
||||
// return $this->lasthookresult;
|
||||
}
|
||||
return null;
|
||||
return $ret;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue
Block a user