diff options
| author | 2019-08-14 22:19:24 +0200 | |
|---|---|---|
| committer | 2019-08-14 22:19:24 +0200 | |
| commit | 7fd88adeb081e2996cad48225bf0c74cfe8b90ef (patch) | |
| tree | bb5edece026aa3fc543dd2a09bd6f3a11ed46a70 /lib/Minz/ExtensionManager.php | |
| parent | c82aff177e53685c66d1bd1ab41a893bef29caef (diff) | |
Add hooks to ExtensionManager (#2482)
Hooks allow to:
- add items in menus
- perform new actions at the end of FreshRSS initialization
Diffstat (limited to 'lib/Minz/ExtensionManager.php')
| -rw-r--r-- | lib/Minz/ExtensionManager.php | 35 |
1 files changed, 34 insertions, 1 deletions
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', @@ -307,6 +323,23 @@ class Minz_ExtensionManager { } /** + * 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. * * This case is simpler than callOneToOne because hooks are called one by |
