Skip to content
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

hookBefore, hookAfter and replace original method? #3

Open
pwFoo opened this issue Dec 31, 2019 · 1 comment
Open

hookBefore, hookAfter and replace original method? #3

pwFoo opened this issue Dec 31, 2019 · 1 comment

Comments

@pwFoo
Copy link

pwFoo commented Dec 31, 2019

Your example show how to modifiy the arguments before executing the original method ("hookBefore").

But would it possible to replace /stop the execution of the original method? Example from a cms I know.

// $event is the current object with all additional features of the cms like "global" variables, ...
$event->replace = true; // do not execute the original method after the hook finishes

Or "hookAfter" original method is executed to manipulate the output?

$event->return = $value; // manipulate or replace the return value of the original method
@pwFoo
Copy link
Author

pwFoo commented Dec 31, 2019

Sorry, hookBefore / hookAfter works as should. Interesting part is how to replace a original method.
If the hooks / methods executed in a loop the return value or a property could be checked to break / skip the loop?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant