From 7fd88adeb081e2996cad48225bf0c74cfe8b90ef Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Wed, 14 Aug 2019 22:19:24 +0200 Subject: Add hooks to ExtensionManager (#2482) Hooks allow to: - add items in menus - perform new actions at the end of FreshRSS initialization --- lib/Minz/ExtensionManager.php | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'lib/Minz/ExtensionManager.php') diff --git a/lib/Minz/ExtensionManager.php b/lib/Minz/ExtensionManager.php index b086c4001..2240b7642 100644 --- a/lib/Minz/ExtensionManager.php +++ b/lib/Minz/ExtensionManager.php @@ -27,14 +27,30 @@ class Minz_ExtensionManager { 'list' => array(), 'signature' => 'OneToOne', ), - 'post_update' => array( // function(none) -> none + 'freshrss_init' => array( // function() -> none 'list' => array(), 'signature' => 'NoneToNone', ), + 'menu_admin_entry' => array( // function() -> string + 'list' => array(), + 'signature' => 'NoneToString', + ), + 'menu_configuration_entry' => array( // function() -> string + 'list' => array(), + 'signature' => 'NoneToString', + ), + 'menu_other_entry' => array( // function() -> string + 'list' => array(), + 'signature' => 'NoneToString', + ), 'nav_reading_modes' => array( // function($readingModes = array) -> array | null 'list' => array(), 'signature' => 'OneToOne', ), + 'post_update' => array( // function(none) -> none + 'list' => array(), + 'signature' => 'NoneToNone', + ), 'simplepie_before_init' => array( // function($simplePie, $feed) -> none 'list' => array(), 'signature' => 'PassArguments', @@ -306,6 +322,23 @@ class Minz_ExtensionManager { return $result; } + /** + * Call a hook which takes no argument and returns a string. + * + * The result is concatenated between each hook and the final string is + * returned. + * + * @param string $hook_name is the hook to call. + * @return a concatenated string, result of the call to all the hooks. + */ + private static function callNoneToString($hook_name) { + $result = ''; + foreach (self::$hook_list[$hook_name]['list'] as $function) { + $result = $result . call_user_func($function); + } + return $result; + } + /** * Call a hook which takes no argument and returns nothing. * -- cgit v1.2.3