-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Add hook enums #8036
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add hook enums #8036
Conversation
app/Controllers/feedController.php
Outdated
|
||
/** @var string|null $urlHooked */ | ||
$urlHooked = Minz_ExtensionManager::callHook('check_url_before_add', $url); | ||
$urlHooked = Minz_ExtensionManager::callHook(Minz_HookType::CheckUrlBeforeAdd->value, $url); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$urlHooked = Minz_ExtensionManager::callHook(Minz_HookType::CheckUrlBeforeAdd->value, $url); | |
$urlHooked = Minz_ExtensionManager::callHook(Minz_HookType::CheckUrlBeforeAdd, $url); |
Suggestion, and for all similar calls. Requires function signature update. See below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was my ultimate goal. But I did not want to spend too much time if this was not the way to follow.
lib/Minz/ExtensionManager.php
Outdated
* @param mixed ...$args additional parameters (for signature, please see Minz_HookType enum). | ||
* @return mixed|void|null final result of the called hook. | ||
*/ | ||
public static function callHook(string $hook_name, ...$args) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public static function callHook(string $hook_name, ...$args) { | |
public static function callHook(Minz_HookType|string $hook_name, ...$args) { | |
if ($hook_name instanceof Minz_HookType) { | |
$hook_name = $hook_name->value; | |
} |
I think that looks like a good step 👍🏻 |
Thank you for your input. I'll continue in that direction and I'll polish this PR. |
185c841
to
cf7a4bb
Compare
Change hard-coded string values to enums. This will allow a more robust code and a better understanding of the hook processes.
@Alkarex Whenever you have time! |
@Alkarex Should I sign my commits? This will rewrite the history though. |
No need for this one, but would be nice for future ones |
Changes proposed in this pull request:
How to test the feature manually:
Pull request checklist:
Additional information can be found in the documentation.