From cc35094bb261cb3185def89d745317fa756560ee Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Tue, 3 Jun 2025 00:16:17 +0200 Subject: Add API endpoint for extensions (#7576) * Add API endpoint for extensions Useful for https://github.com/FreshRSS/FreshRSS/issues/7572 * Support PATH_INFO Now also support being invoked like `/api/misc.php/Extension%20Name/` * More documentation --- lib/Minz/ExtensionManager.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'lib') diff --git a/lib/Minz/ExtensionManager.php b/lib/Minz/ExtensionManager.php index fea1f5879..b1d499392 100644 --- a/lib/Minz/ExtensionManager.php +++ b/lib/Minz/ExtensionManager.php @@ -22,6 +22,10 @@ final class Minz_ExtensionManager { * @var array,'signature':'NoneToNone'|'NoneToString'|'OneToOne'|'PassArguments'}> */ private static array $hook_list = [ + 'api_misc' => [ // function(): void + 'list' => [], + 'signature' => 'NoneToNone', + ], 'check_url_before_add' => [ // function($url) -> Url | null 'list' => [], 'signature' => 'OneToOne', @@ -429,4 +433,18 @@ final class Minz_ExtensionManager { call_user_func($function); } } + + /** + * Call a hook which takes no argument and returns nothing. + * Same as callHookVoid but only calls the first extension. + * + * @param string $hook_name is the hook to call. + */ + public static function callHookUnique(string $hook_name): bool { + foreach (self::$hook_list[$hook_name]['list'] ?? [] as $function) { + call_user_func($function); + return true; + } + return false; + } } -- cgit v1.2.3