From dac275ce3a3529494af1b86b803f140a1a55424e Mon Sep 17 00:00:00 2001 From: Alexis Degrugillier Date: Wed, 1 Oct 2025 05:01:31 -0400 Subject: Add support for extension priority (#8038) Extension can now define their hook priority. This will allow to define the order in which hooks are triggered. See #7110 Closes #7110 Changes proposed in this pull request: - Add support for extension priority How to test the feature manually: 1. Create an extension with 2 hooks on the same hook type but different priority 2. The hooks must be prepending the title with different values 3. Validate that changing the hook priority changes the final title accordingly. --- lib/Minz/Extension.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/Minz/Extension.php') diff --git a/lib/Minz/Extension.php b/lib/Minz/Extension.php index 4d529f1d4..a35272b03 100644 --- a/lib/Minz/Extension.php +++ b/lib/Minz/Extension.php @@ -258,9 +258,10 @@ abstract class Minz_Extension { * * @param string $hook_name the hook name (must exist). * @param callable $hook_function the function name to call (must be callable). + * @param int $priority the priority of the hook, default priority is 0, the higher the value the lower the priority */ - final protected function registerHook(string $hook_name, $hook_function): void { - Minz_ExtensionManager::addHook($hook_name, $hook_function); + final protected function registerHook(string $hook_name, $hook_function, int $priority = Minz_Hook::DEFAULT_PRIORITY): void { + Minz_ExtensionManager::addHook($hook_name, $hook_function, $priority); } /** @param 'system'|'user' $type */ -- cgit v1.2.3