MediaWiki master
MediaWiki\DomainEvent\DomainEventSource Interface Reference

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 changed to the persistent state of 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.
 
const INVOCATION_MODE = 'invocation'
 
const INVOKE_AFTER_COMMIT = 'AfterCommit'
 Listeners will be invoked after the transaction that produced the event was committed successfully.
 

Detailed Description

Service object for registering listeners for domain events.

Since
1.44
Stability: unstable
until 1.45

Definition at line 10 of file DomainEventSource.php.

Member Function Documentation

◆ registerListener()

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 changed to the persistent state of the local wiki.

Listeners should make sure to apply DEFAULT_OPTIONS to $options.

Parameters
string$eventType
callable$listener
array$optionsOptions that control how the listener is invoked. Options may be implementation specific can could control things like invocation order (priority) and error handling. Well known keys are:
  • self::INVOCATION_MODE: one of the invocation modes defined in this class, e.g. self::INVOKE_AFTER_COMMIT.

Implemented in MediaWiki\DomainEvent\EventDispatchEngine.

◆ registerSubscriber()

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.

Parameters
DomainEventSubscriber | array$subscriber
  • object: a DomainEventSubscriber
  • array: An object spec suitable for use with ObjectFactory. The array must use the key 'events' to specify which events will trigger application of the subscriber.

Implemented in MediaWiki\DomainEvent\EventDispatchEngine.

Referenced by MediaWiki\Registration\ExtensionRegistry\registerListeners().

Member Data Documentation

◆ DEFAULT_LISTENER_OPTIONS

const MediaWiki\DomainEvent\DomainEventSource::DEFAULT_LISTENER_OPTIONS
Initial value:
= [
self::INVOCATION_MODE => self::INVOKE_AFTER_COMMIT
]
const INVOKE_AFTER_COMMIT
Listeners will be invoked after the transaction that produced the event was committed successfully.

Default options to apply when registering listeners.

Definition at line 35 of file DomainEventSource.php.

◆ INVOCATION_MODE

const MediaWiki\DomainEvent\DomainEventSource::INVOCATION_MODE = 'invocation'

Definition at line 30 of file DomainEventSource.php.

◆ INVOKE_AFTER_COMMIT

const MediaWiki\DomainEvent\DomainEventSource::INVOKE_AFTER_COMMIT = 'AfterCommit'

Listeners will be invoked after the transaction that produced the event was committed successfully.

Delivery guarantees depend on the 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.

Definition at line 28 of file DomainEventSource.php.


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