HookEvent is a type provided to hook functions with information about the event.
// Example
$wire->addHookAfter('Pages::saved', function(HookEvent $event) {
$page = $event->arguments(0);
$event->message("You saved page $page->path");
});
Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the Hook
class also inherits all the methods and properties of: WireData and Wire.
Common
Name | Return | Summary | |
---|---|---|---|
$event->arguments() $event->arguments() $event->arguments(int $n = null, mixed $value = null) | array null mixed | Retrieve or set a hooked function argument Can also be used as property: $event->arguments | |
$event->argumentsByName() $event->argumentsByName() $event->argumentsByName(string $n = '') | mixed array | Returns an array of all arguments indexed by name, or the value of a single specified argument | |
$event->cancelHooks | bool | When true, all remaining hooks will be cancelled, making this Hook | |
$event->get() $event->get($key) $event->get($key) | mixed null | Get | |
$event->id | string | A unique identifier string that may be used with a call to `Wire::removeHook()`. | |
$event->method | string | The name of the method that was called to generate the Hook event. | |
$event->object | Wire WireData WireArray Module | Instance of the object where the Hook event originated. | |
$event->options | array | An optional array of user-specified data that gets sent to the hooked function. The hook handling method may access it from $event->data. Also includes all the default hook properties. | |
$event->removeHook() $event->removeHook($hookId) $event->removeHook($hookId) | Hook WireData | Remove a hook by ID | |
$event->replace | bool | Set to boolean true in a 'before' hook if you want to prevent execution of the original hooked function. In such a case, your hook is replacing the function entirely. Not recommended, so be careful with this. | |
$event->return | mixed | Applicable only for 'after' or ('replace' + 'before' hooks), contains the value returned by the above mentioned method. The hook handling method may modify this return value. | |
$event->when | string | In an active hook, contains either the string 'before' or 'after', indicating whether it is executing before or after the hooked method. |
Additional methods and properties
In addition to the methods and properties above, Hook
API reference based on ProcessWire core version 3.0.236