Register a hook against the MENU_ITEMS_ASSEMBLY event
This commit is contained in:
parent
a91001fb25
commit
8bd362aa01
1 changed files with 17 additions and 1 deletions
18
action.php
18
action.php
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue