Interface EventManagerInterface
Dispatches a new event to all configured listeners
Returns a list of all listeners for an eventKey in the order they should be called
Remove a listener from the active listeners.
Adds a new listener to an event.
dispatch(Cake\Event\EventInterface|string $event): Cake\Event\EventInterface
Dispatches a new event to all configured listeners
Cake\Event\EventInterface|string
$event The event key name or instance of EventInterface.
Cake\Event\EventInterface
listeners(string $eventKey): array
Returns a list of all listeners for an eventKey in the order they should be called
string
$eventKey Event key.
array
off(Cake\Event\EventListenerInterface|callable|string $eventKey, Cake\Event\EventListenerInterface|callable|null $callable = null): $this
Remove a listener from the active listeners.
Remove a EventListenerInterface entirely:
$manager->off($listener);
Remove all listeners for a given event:
$manager->off('My.event');
Remove a specific listener:
$manager->off('My.event', $callback);
Remove a callback from all events:
$manager->off($callback);
Cake\Event\EventListenerInterface|callable|string
$eventKey The event unique identifier name with which the callback has been associated, or the $listener you want to remove.
Cake\Event\EventListenerInterface|callable|null
$callable optional The callback you want to detach.
$this
on(Cake\Event\EventListenerInterface|string $eventKey, callable|array $options = [], callable|null $callable = null): $this
Adds a new listener to an event.
A variadic interface to add listeners that emulates jQuery.on().
Binding an EventListenerInterface:
$eventManager->on($listener);
Binding with no options:
$eventManager->on('Model.beforeSave', $callable);
Binding with options:
$eventManager->on('Model.beforeSave', ['priority' => 90], $callable);
Cake\Event\EventListenerInterface|string
$eventKey The event unique identifier name with which the callback will be associated. If $eventKey is an instance of Cake\Event\EventListenerInterface its events will be bound using the implementedEvents()
methods.
callable|array
$options optional Either an array of options or the callable you wish to bind to $eventKey. If an array of options, the priority
key can be used to define the order. Priorities are treated as queues. Lower values are called before higher ones, and multiple attachments added to the same priority queue will be treated in the order of insertion.
callable|null
$callable optional The callable function you want invoked.
$this
InvalidArgumentException
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.4/interface-Cake.Event.EventManagerInterface.html