\Piko\EventHandlerTrait
An instance using this trait become an event handler : it can dispatches events and listen to them.
Properties summary
Name | Description |
---|---|
protected $eventDispatcher |
|
protected $listenerProvider |
Methods summary
Name | Description |
---|---|
public on |
Registers an event listener. |
public trigger |
Trigger an event that may be listen by event liste… |
Properties
protected $eventDispatcher : ?\Psr\EventDispatcher\EventDispatcherInterface
protected $listenerProvider : ?\Piko\ListenerProvider
Methods
public on(): mixed
public on(string $eventClassName, callable $callback, int|null $priority = null): mixed
Registers an event listener.
Parameters
$eventClassName : The class name of the event to listen for.
$callback : The callback to execute when the event is dispatched.
$priority (default: null): Optional priority for the listener (higher means earlier execution).
Return:
mixed
public trigger(): object
public trigger(object $event): object
Trigger an event that may be listen by event listeners.
Parameters
$event : The event instance to dispatch.
Return:
object The same event instance that may be altered by event listeners.