MediaWiki master
|
Service object for registering listeners for domain events. More...
Inherited by MediaWiki\DomainEvent\EventDispatchEngine.
Public Member Functions | |
registerListener (string $eventType, $listener, array $options=self::DEFAULT_LISTENER_OPTIONS) | |
Add a listener that will be notified on events of the given type, triggered by a change to an entity on the local wiki. | |
registerSubscriber ( $subscriber) | |
Register the given subscriber to this event source. | |
Public Attributes | |
const | DEFAULT_LISTENER_OPTIONS = [] |
Default options to apply when registering listeners. | |
Service object for registering listeners for domain events.
Definition at line 12 of file DomainEventSource.php.
MediaWiki\DomainEvent\DomainEventSource::registerListener | ( | string | $eventType, |
$listener, | |||
array | $options = self::DEFAULT_LISTENER_OPTIONS ) |
Add a listener that will be notified on events of the given type, triggered by a change to an entity on the local wiki.
Listeners will be invoked after the transaction that produced the event was committed successfully. Delivery guarantees depend on the respective DomainEventDispatcher implementation.
In a web request, listeners should be invoked after the response has been sent to the client, but still within the current process.
Listeners may be invoked immediately if there is no active transaction round associated with the ConnectionProvider passed to DomainEventDispatcher::dispatch().
Listeners should be implemented to be idempotent, that is, calling them multiple times with the same parameters should produce the same outcome.
string | $eventType | |
callable | $listener | |
array | $options | Currently unused. In the future, $options may
|
Implemented in MediaWiki\DomainEvent\EventDispatchEngine.
MediaWiki\DomainEvent\DomainEventSource::registerSubscriber | ( | $subscriber | ) |
Register the given subscriber to this event source.
A subscriber is a way to bundle related listeners, typically by implementing them as methods on the subscriber object.
If the subscriber is supplied as a spec array, instantiation and application may be deferred until one of the relevant events is triggered.
DomainEventSubscriber | array | $subscriber |
|
Implemented in MediaWiki\DomainEvent\EventDispatchEngine.
Referenced by MediaWiki\Registration\ExtensionRegistry\registerListeners().
const MediaWiki\DomainEvent\DomainEventSource::DEFAULT_LISTENER_OPTIONS = [] |
Default options to apply when registering listeners.
In the future, options may convey things like the listener priority or error handling.
Definition at line 19 of file DomainEventSource.php.