mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-12 12:41:30 +00:00
add new method getHookObjects() which returns all registered hook objects
This commit is contained in:
parent
ce79c8e8cd
commit
4e9cadeca6
|
@ -67,6 +67,10 @@ class SeedDMS_View_Common {
|
||||||
* This function will execute all registered hooks in the order
|
* This function will execute all registered hooks in the order
|
||||||
* they were registered.
|
* they were registered.
|
||||||
*
|
*
|
||||||
|
* Attention: as func_get_arg() cannot handle references passed to the hook,
|
||||||
|
* callHook() should not be called if that is required. In that case get
|
||||||
|
* a list of hook objects with getHookObjects() and call the hooks yourself.
|
||||||
|
*
|
||||||
* @params string $hook name of hook
|
* @params string $hook name of hook
|
||||||
* @return string concatenated string of whatever the hook function returns
|
* @return string concatenated string of whatever the hook function returns
|
||||||
*/
|
*/
|
||||||
|
@ -105,6 +109,35 @@ class SeedDMS_View_Common {
|
||||||
return $ret;
|
return $ret;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all hook objects for the given or calling class
|
||||||
|
*
|
||||||
|
* <code>
|
||||||
|
* <?php
|
||||||
|
* $hookObjs = $this->getHookObjects();
|
||||||
|
* foreach($hookObjs as $hookObj) {
|
||||||
|
* if (method_exists($hookObj, $hook)) {
|
||||||
|
* $ret = $hookObj->$hook($this, ...);
|
||||||
|
* ...
|
||||||
|
* }
|
||||||
|
* }
|
||||||
|
* ?>
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
|
* @params string $classname name of class (current class if left empty)
|
||||||
|
* @return array list of hook objects registered for the class
|
||||||
|
*/
|
||||||
|
function getHookObjects($classname='') { /* {{{ */
|
||||||
|
if($classname)
|
||||||
|
$tmp = explode('_', $classname);
|
||||||
|
else
|
||||||
|
$tmp = explode('_', get_class($this));
|
||||||
|
if(isset($GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp[2])])) {
|
||||||
|
return $GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp[2])];
|
||||||
|
}
|
||||||
|
return array();
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a hook is registered
|
* Check if a hook is registered
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue
Block a user