A class to manage hooks, and to call hook handlers.
This class is capable of managing a flexible list of hooks, registering handlers for those hooks, and calling the handlers
| package |
CMS |
|---|---|
| license |
GPL |
| since | 2.2 |
| author |
Robert Campbell calguy1000@gmail.com |
add_hook(string $name, callable $callable, integer $priority = self::PRIORITY_NORMAL)
string $nameThe hook name. If the hook does not already exist, it is added.
callable $callableA callable function, or a string representing a callable function. Closures are also supported.
integer $priorityThe priority of the handler.
do_hook() : mixed
This method accepts variable arguments. The first argument (required) is the name of the hook to execute. Further arguments will be passed to the various handlers.
mixed
The output of this method depends on the hook.
do_hook_first_result() : mixed
This method accepts variable arguments. The first argument (required) is the name of the hook to execute. Further arguments will be passed to the various handlers.
This method will always pass the same input arguments to each hook handler.
mixed
The output of this method depends on the hook.
do_hook_accumulate() : array
This method accepts variable arguments. The first argument (required) is the name of the hook to execute. Further arguments will be passed to the various handlers.
The data returned in the $params array will be appended to the output array.
array
Mixed data, as it cannot be ascertained what data is passed back from handlers.
PRIORITY_HIGH
PRIORITY_NORMAL
PRIORITY_LOW