Objects implementing this interface can emit events.
Objects with this interface can trigger events, and have an event manager retrieved from them.
The {@link \Cake\Event\EventDispatcherTrait} lets you easily implement this interface.
Represents the transport class of events across the system. It receives a name, subject and an optional payload. The name can be any string that uniquely identifies the event across the application, while the subject represents the object that the event applies to.
Objects implementing this interface should declare the implementedEvents() method
to notify the event manager what methods should be called when an event is triggered.
Interface EventManagerInterface
Connects event listeners declared via PHP attributes to an event manager.
Reads event listener attribute metadata from the configured AttributeResolver collection and registers the resolved callables on the provided EventManagerInterface.
Usage within Application::events():
public function events(EventManagerInterface $eventManager): EventManagerInterface
{
new AttributeEventListenerConnector(
$eventManager,
$this->getContainer()->get(...),
)->connect();
return $eventManager;
}
Or using the connector directly with a custom config:
(new AttributeEventListenerConnector($eventManager))->connect('myConfig');
Class Event
The Event List
The event manager is responsible for keeping track of event listeners, passing the correct data to them, and firing them in the correct order, when associated events are triggered. You can create multiple instances of this object to manage local events or keep a single instance and pass it around to manage all events in your app.
Implements Cake\Event\EventDispatcherInterface.
Shared registration loop used by BaseApplication and BasePlugin to attach
declarative event listeners to an event manager.
Each listener must be a class string implementing EventListenerInterface;
the trait resolves it through the given DI container so constructor
dependencies can be injected.