From 8bd362aa018e350b77348e0b598715fd2a24084f Mon Sep 17 00:00:00 2001 From: vv221 Date: Thu, 2 Apr 2020 23:48:40 +0200 Subject: [PATCH] Register a hook against the MENU_ITEMS_ASSEMBLY event --- action.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/action.php b/action.php index 3b5d4a9..88d04bc 100644 --- a/action.php +++ b/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); } }