A class to add hook handlers and emit hooks of various types.
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.3 |
| 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.
in_hook(null|string $name = null) : boolean
null|string $nameThe hook name to test for. If null is provided, the system will return true if any hook is being processed.
boolean
emit() : 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.
emit_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.
emit_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