aboutsummaryrefslogtreecommitdiff
path: root/lib/Minz/ExtensionManager.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Minz/ExtensionManager.php')
-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;
+ }
}