MediaWiki master
MediaWiki\DomainEvent\EventDispatchEngine Class Reference

Implementation of DomainEventDispatcher and DomainEventSource based on HookContainer and DeferredUpdates. More...

Inherits MediaWiki\DomainEvent\DomainEventDispatcher, and MediaWiki\DomainEvent\DomainEventSource.

Collaboration diagram for MediaWiki\DomainEvent\EventDispatchEngine:

Public Member Functions

 __construct (ObjectFactory $objectFactory)
 
 dispatch (DomainEvent $event, IConnectionProvider $dbProvider)
 Emit the given event to any listeners that have been registered for the respective event type.
 
 registerListener (string $eventType, $listener, array $options=self::DEFAULT_LISTENER_OPTIONS)
 Add a listener that will be notified on events of the given type.
 
 registerSubscriber ( $subscriber)
 

Additional Inherited Members

- Public Attributes inherited from MediaWiki\DomainEvent\DomainEventSource
const DEFAULT_LISTENER_OPTIONS = []
 Default options to apply when registering listeners.
 

Detailed Description

Implementation of DomainEventDispatcher and DomainEventSource based on HookContainer and DeferredUpdates.

Since this implementation of DomainEventDispatcher is based on HookContainer, each event type also function as a hook name. This effectively means that there are two ways to get informed about an event: asynchronously, using a listener registered with an DomainEventSource; or synchronously, using a hook handler registered with the HookContainer.

Access: internal

Definition at line 22 of file EventDispatchEngine.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\DomainEvent\EventDispatchEngine::__construct ( ObjectFactory $objectFactory)

Definition at line 39 of file EventDispatchEngine.php.

Member Function Documentation

◆ dispatch()

MediaWiki\DomainEvent\EventDispatchEngine::dispatch ( DomainEvent $event,
IConnectionProvider $dbProvider )

Emit the given event to any listeners that have been registered for the respective event type.

Listeners are invoked through DeferredUpdates.

Implements MediaWiki\DomainEvent\DomainEventDispatcher.

Definition at line 49 of file EventDispatchEngine.php.

◆ registerListener()

MediaWiki\DomainEvent\EventDispatchEngine::registerListener ( string $eventType,
$listener,
array $options = self::DEFAULT_LISTENER_OPTIONS )

Add a listener that will be notified on events of the given type.

Parameters
string$eventType
callable$listener
array$optionsCurrently unused. In the future, $options may convey things like the listener priority or error handling.

Implements MediaWiki\DomainEvent\DomainEventSource.

Definition at line 78 of file EventDispatchEngine.php.

◆ registerSubscriber()

MediaWiki\DomainEvent\EventDispatchEngine::registerSubscriber ( $subscriber)
Parameters
DomainEventSubscriber | array$subscriber

Implements MediaWiki\DomainEvent\DomainEventSource.

Definition at line 93 of file EventDispatchEngine.php.


The documentation for this class was generated from the following file: