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,11 +181,20 @@ class SeedDMS_View_Common {
* null if no hook was called * null if no hook was called
*/ */
public function hasHook($hook) { /* {{{ */ public function hasHook($hook) { /* {{{ */
$tmps = array();
$tmp = explode('_', get_class($this)); $tmp = explode('_', get_class($this));
if(isset($GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp[2])])) { $tmps[] = $tmp[2];
foreach($GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp[2])] as $hookObj) { $tmp = explode('_', get_parent_class($this));
if (method_exists($hookObj, $hook)) { $tmps[] = $tmp[2];
return true; /* 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;
}
} }
} }
} }