aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2023-03-29 21:31:25 +0200
committerGravatar GitHub <noreply@github.com> 2023-03-29 21:31:25 +0200
commit6a5857ea5f1de73d042e389ae0f1a827ec414e6a (patch)
tree17b7e66317177fd9c4bc07fd182e5b7a2a94dd56 /lib
parentea877080108aa5846d07a0039083d3cc6fdc2ba9 (diff)
Simplify extension method (#5234)
One parameter was not used Furthermore, that unused parameter was preventing simpler calls (i.e. without a dedicated extension class). Now it is possible to register a call back with a lamda: ```php Minz_ExtensionManager::addHook('feed_before_actualize', function () { // Hello }); ```
Diffstat (limited to 'lib')
-rw-r--r--lib/Minz/Extension.php2
-rw-r--r--lib/Minz/ExtensionManager.php8
2 files changed, 2 insertions, 8 deletions
diff --git a/lib/Minz/Extension.php b/lib/Minz/Extension.php
index a280676c1..d1dabe8d5 100644
--- a/lib/Minz/Extension.php
+++ b/lib/Minz/Extension.php
@@ -195,7 +195,7 @@ abstract class Minz_Extension {
* @param callable-string|array<string> $hook_function the function name to call (must be callable).
*/
public function registerHook($hook_name, $hook_function) {
- Minz_ExtensionManager::addHook($hook_name, $hook_function, $this);
+ Minz_ExtensionManager::addHook($hook_name, $hook_function);
}
/**
diff --git a/lib/Minz/ExtensionManager.php b/lib/Minz/ExtensionManager.php
index 3fcbb2ab3..8625217ec 100644
--- a/lib/Minz/ExtensionManager.php
+++ b/lib/Minz/ExtensionManager.php
@@ -76,8 +76,6 @@ class Minz_ExtensionManager {
'signature' => 'PassArguments',
),
);
- // @phpstan-ignore-next-line
- private static $ext_to_hooks = array();
/**
* Initialize the extension manager by loading extensions in EXTENSIONS_PATH.
@@ -202,8 +200,6 @@ class Minz_ExtensionManager {
in_array($name, self::$ext_auto_enabled, true))) { //Legacy format < FreshRSS 1.11.1
self::enable($ext->getName());
}
-
- self::$ext_to_hooks[$name] = array();
}
/**
@@ -280,12 +276,10 @@ class Minz_ExtensionManager {
*
* @param string $hook_name the hook name (must exist).
* @param callable $hook_function the function name to call (must be callable).
- * @param Minz_Extension $ext the extension which register the hook.
*/
- public static function addHook($hook_name, $hook_function, $ext) {
+ public static function addHook($hook_name, $hook_function) {
if (isset(self::$hook_list[$hook_name]) && is_callable($hook_function)) {
self::$hook_list[$hook_name]['list'][] = $hook_function;
- self::$ext_to_hooks[$ext->getName()][] = $hook_name;
}
}