Provides the implementation for calling hooks in ProcessWire
Unlike __call, this method won't trigger an Exception if the hook and method don't exist. Instead it returns a result array containing information about the call.
Usage
// basic usage
$array = $hooks->runHooks(Wire $object, string $method, array $arguments);
// usage with all arguments
$array = $hooks->runHooks(Wire $object, string $method, array $arguments, $type = 'method');
Arguments
Name | Type(s) | Description |
---|---|---|
object | Wire | |
method | string | Method or property to run hooks for. |
arguments | array | Arguments passed to the method and hook. |
type (optional) | string, array | May be any one of the following:
|
Return value
array
Returns an array with the following information: [return] => The value returned from the hook or NULL if no value returned or hook didn't exist. [numHooksRun] => The number of hooks that were actually run. [methodExists] => Did the hook method exist as a real method in the class? (i.e. with 3 underscores ___method). [replace] => Set by the hook at runtime if it wants to prevent execution of the original hooked method.
API reference based on ProcessWire core version 3.0.236