Skip to content

EventDispatcher

github-actions edited this page Apr 6, 2026 · 1 revision

Dispatch events through PSR-14 listener providers and optional named wrappers.

This dispatcher resolves listeners for the original event object first. When the event is not already a

  • See: \FastForward\EventDispatcher\Event\NamedEvent, it dispatches a named wrapper afterward so listeners registered by string identifier can observe the same event instance.

  • Full name: \FastForward\EventDispatcher\EventDispatcher
  • This class is marked as final and can't be subclassed
  • This class implements: EventDispatcherInterface
  • This class is a Final class

See Also:

  • \Psr\EventDispatcher\EventDispatcherInterface

Methods

__construct

Create a dispatcher backed by the provided listener provider.

public __construct(\Psr\EventDispatcher\ListenerProviderInterface $listenerProvider): mixed

Parameters:

Parameter Type Description
$listenerProvider \Psr\EventDispatcher\ListenerProviderInterface listener provider used to resolve event listeners

dispatch

Dispatch an event to all matching listeners.

public dispatch(object $event, string|null $eventName = null): object

Stoppable events are returned immediately when propagation has already been halted. When a listener throws during a non-error dispatch, the dispatcher emits an

  • See: \FastForward\EventDispatcher\Event\ErrorEvent before rethrowing the original throwable.

Parameters:

Parameter Type Description
$event object event object to dispatch
$eventName string|null explicit name for the generated {@see \FastForward\EventDispatcher\Event\NamedEvent} wrapper

Return Value:

the dispatched event instance

Throws:

thrown when a listener failure is not absorbed by an error-event listener


Clone this wiki locally