Register a hook against the MENU_ITEMS_ASSEMBLY event

This commit is contained in:
vv221 2020-04-02 23:48:40 +02:00
parent a91001fb25
commit 8bd362aa01

View file

@ -18,6 +18,22 @@ class action_plugin_tabpage extends DokuWiki_Action_Plugin {
* @param Doku_Event_Handler $controller
*/
public function register(Doku_Event_Handler $controller) {
trigger_error('register() not implemented in '.get_class($this), E_USER_WARNING);
$controller->register_hook('MENU_ITEMS_ASSEMBLY', 'AFTER', $this, 'addMenuItem');
}
/**
* Add new items to the page menu
*
* @param Doku_Event $event
*/
public function addMenuItem(Doku_Event $event) {
// Check that this method has been called in the expected context
if ( $event->name !== 'MENU_ITEMS_ASSEMBLY' ) {
$message = "Tabpage plugin error:";
$message .= "addMenuItem method should only be called by \"MENU_ITEMS_ASSEMBLY\" event";
$message .= ", but it has been called by \"$event->name\".";
throw new Exception($message);
}
trigger_error('addMenuItem() not implemented in '.get_class($this), E_USER_WARNING);
}
}