hookphp
hookphp copied to clipboard
hookBefore, hookAfter and replace original method?
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
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?