do not call hook documentNavigationBar with callHook, but iterate over hookObjs

This commit is contained in:
Uwe Steinmann 2022-06-16 12:44:53 +02:00
parent c3f5a637f6
commit d3e6cecaa7
2 changed files with 6 additions and 16 deletions

View File

@ -751,21 +751,16 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
$menuitems['transfer_document'] = array('link'=>$this->params['settings']->_httpRoot."out/out.TransferDocument". $docid, 'label'=>getMLText('transfer_document')); $menuitems['transfer_document'] = array('link'=>$this->params['settings']->_httpRoot."out/out.TransferDocument". $docid, 'label'=>getMLText('transfer_document'));
} }
/* Check if hook exists because otherwise callHook() will override $menuitems */ /* Do not use $this->callHook() because $menuitems must be returned by the the
if($this->hasHook('documentNavigationBar')) * first hook and passed to next hook. $this->callHook() will just pass
$menuitems = $this->callHook('documentNavigationBar', $document, $menuitems); * the menuitems to each single hook. Hence, the last hook will win.
/* Do not use $this->callHook() because $menuitems must be returned by the hook
* or left unchanged
*/ */
/*
$hookObjs = $this->getHookObjects(); $hookObjs = $this->getHookObjects();
foreach($hookObjs as $hookObj) { foreach($hookObjs as $hookObj) {
if (method_exists($hookObj, 'documentNavigationBar')) { if (method_exists($hookObj, 'documentNavigationBar')) {
$menuitems = $hookObj->documentNavigationBar($this, $document, $menuitems); $menuitems = $hookObj->documentNavigationBar($this, $document, $menuitems);
} }
} }
*/
self::showNavigationBar($menuitems); self::showNavigationBar($menuitems);

View File

@ -748,21 +748,16 @@ background-image: linear-gradient(to bottom, #882222, #111111);;
$menuitems['transfer_document'] = array('link'=>$this->params['settings']->_httpRoot."out/out.TransferDocument". $docid, 'label'=>getMLText('transfer_document')); $menuitems['transfer_document'] = array('link'=>$this->params['settings']->_httpRoot."out/out.TransferDocument". $docid, 'label'=>getMLText('transfer_document'));
} }
/* Check if hook exists because otherwise callHook() will override $menuitems */ /* Do not use $this->callHook() because $menuitems must be returned by the the
if($this->hasHook('documentNavigationBar')) * first hook and passed to next hook. $this->callHook() will just pass
$menuitems = $this->callHook('documentNavigationBar', $document, $menuitems); * the menuitems to each single hook. Hence, the last hook will win.
/* Do not use $this->callHook() because $menuitems must be returned by the hook
* or left unchanged
*/ */
/*
$hookObjs = $this->getHookObjects(); $hookObjs = $this->getHookObjects();
foreach($hookObjs as $hookObj) { foreach($hookObjs as $hookObj) {
if (method_exists($hookObj, 'documentNavigationBar')) { if (method_exists($hookObj, 'documentNavigationBar')) {
$menuitems = $hookObj->documentNavigationBar($this, $document, $menuitems); $menuitems = $hookObj->documentNavigationBar($this, $document, $menuitems);
} }
} }
*/
self::showNavigationBar($menuitems); self::showNavigationBar($menuitems);
} /* }}} */ } /* }}} */