aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2025-06-03 00:16:17 +0200
committerGravatar GitHub <noreply@github.com> 2025-06-03 00:16:17 +0200
commitcc35094bb261cb3185def89d745317fa756560ee (patch)
tree0d94bbd1dfe1013101dd96b8dbfa975d275ddf7b /lib
parent430d4e898e60ec1892d7191cf6e039aaf693822f (diff)
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
Diffstat (limited to 'lib')
-rw-r--r--lib/Minz/ExtensionManager.php18
1 files changed, 18 insertions, 0 deletions
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<string,array{'list':array<callable>,'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;
+ }
}