check for hook attached to parent class in hasHook()

This commit is contained in:
Uwe Steinmann 2019-10-01 14:06:00 +02:00
parent ae4a65e8bc
commit 31697278d1

View File

@ -181,14 +181,23 @@ class SeedDMS_View_Common {
* null if no hook was called
*/
public function hasHook($hook) { /* {{{ */
$tmps = array();
$tmp = explode('_', get_class($this));
if(isset($GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp[2])])) {
foreach($GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp[2])] as $hookObj) {
$tmps[] = $tmp[2];
$tmp = explode('_', get_parent_class($this));
$tmps[] = $tmp[2];
/* Run array_unique() in case the parent class has the same suffix */
$tmps = array_unique($tmps);
$ret = null;
foreach($tmps as $tmp) {
if(isset($GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp)])) {
foreach($GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp)] as $hookObj) {
if (method_exists($hookObj, $hook)) {
return true;
}
}
}
}
return false;
} /* }}} */