From 4f1c27255c371e8863a14b1e012b31555b3d5f38 Mon Sep 17 00:00:00 2001 From: Anika Kaiser Date: Wed, 6 Mar 2019 23:24:51 +0100 Subject: [PATCH] Update 60.plugins.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With custom hooks, you can place your plugin's data anywhere you want. For example, you have a footer and you want to have links in your footer. There is a link plugin that displays links in the SiteBar with "". If you put this code in your footer, all plugins that use "siteSidebar" will be placed in your footer. With my pull request you can now create your own hooks and it can be guaranteed that only a single plugin places its data there but only if its the only plugin implementing your custom hook. How to create custom hooks: in your plugin.php you have to place a public function "registerHooks" returning an array of String. ยดยดยด public function registerHooks() { return array( "akLinks", "akBusinessHours" ); } ``` --- bl-kernel/boot/rules/60.plugins.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bl-kernel/boot/rules/60.plugins.php b/bl-kernel/boot/rules/60.plugins.php index 5d12ccd4..1edb520e 100644 --- a/bl-kernel/boot/rules/60.plugins.php +++ b/bl-kernel/boot/rules/60.plugins.php @@ -104,6 +104,20 @@ function buildPlugins() array_push($plugins[$event], $Plugin); } } + + /* THIS PART IS FOR CUSTOM HOOKS */ + if(method_exists($Plugin, "registerHooks")) + { + foreach (call_user_func("{$Plugin->className()}::registerHooks") as $customEvent) + { + if (method_exists($Plugin, $customEvent)) + { + $plugins[$customEvent] = array(); + array_push($plugins[$customEvent], $Plugin); + } + } + } + /* THIS PART IS FOR CUSTOM HOOKS */ } uasort($plugins['siteSidebar'], function ($a, $b) {