MediaWiki master
MediaWiki\DomainEvent\DomainEventIngress Class Reference

Base class for event ingress objects. More...

Inherits MediaWiki\DomainEvent\InitializableDomainEventSubscriber.

Inherited by MediaWiki\Languages\LanguageEventIngress, MediaWiki\RecentChanges\ChangeTrackingEventIngress, MediaWiki\ResourceLoader\ResourceLoaderEventIngress, and MediaWiki\Search\SearchEventIngress.

Collaboration diagram for MediaWiki\DomainEvent\DomainEventIngress:

Public Member Functions

 initSubscriber (array $options)
 Called by DomainEventDispatcher to provide access to the list of events to subscribe to and any other relevant information from the extension.json.
 
 registerListeners (DomainEventSource $eventSource)
 This default implementation of registerListeners() will automatically register a listener method for each event passed to initEvents() or initSubscriber().
 

Protected Member Functions

 getListenerOptions (string $eventType, string $suffix)
 Placeholder method for allowing subclasses to define listener options.
 
 registerForEvent (DomainEventSource $eventSource, string $eventType)
 Registered any listener methods for the given event.
 

Detailed Description

Base class for event ingress objects.

Event ingress objects implements listener methods for events that a component or extension is interested in. It is responsible for determining which event should trigger which logic in the component and for mapping from the model used by the emitter of the event to the component's own model.

DomainEventIngress implements InitializableDomainEventSubscriber so it can be registered with and initialized by a DomainEventSource. Registration is typically done in the form of an object spec for lazy instantiation. For extensions' ingress objects that object spec can be provided in the DomainEventIngresses section of extension.json.

After instantiating a subscriber (typically a subclass of DomainEventIngress), the event source will call initSubscriber() to initialize the subscriber and then registerListeners() to allow the subscriber to register listeners for the events it is interested in.

This class provides a default implementation of registerListeners() that will attempt to find listener methods for the events the ingress object is interested in. Listener methods must have a name based on the event type, following the pattern "handle{$eventType}Event".

The set of events the ingress objects is interested in must be provided as part of the $options array passed to initSubscriber() when it is called by the event source. This array is simply the same as the object spec used to register the ingress object with the event source. That means that for extensions, the list of events is given as part of the ingress object's spec in extension.json.

Since
1.44
See also
docs/Events.md
https://www.mediawiki.org/wiki/Manual:Domain_events

Definition at line 44 of file DomainEventIngress.php.

Member Function Documentation

◆ getListenerOptions()

MediaWiki\DomainEvent\DomainEventIngress::getListenerOptions ( string $eventType,
string $suffix )
protected

Placeholder method for allowing subclasses to define listener options.

The default implementation could make use of method attributes in the future, e.g. to determine a listener's priority.

Stability: unstable
for now, intended to become stable to override once the signature is clear.

Definition at line 136 of file DomainEventIngress.php.

◆ initSubscriber()

MediaWiki\DomainEvent\DomainEventIngress::initSubscriber ( array $options)

Called by DomainEventDispatcher to provide access to the list of events to subscribe to and any other relevant information from the extension.json.

Known keys used in $options:

  • 'events': a list of events the ingress object should register listeners for (required). The object must implement a listener method for each of the events listed here, using the following pattern: public function handleSomeEventEvent( SomeEvent $event ).
Parameters
array$optionsthe object spec describing the subscriber, typically from extension.json.

Implements MediaWiki\DomainEvent\InitializableDomainEventSubscriber.

Definition at line 64 of file DomainEventIngress.php.

◆ registerForEvent()

MediaWiki\DomainEvent\DomainEventIngress::registerForEvent ( DomainEventSource $eventSource,
string $eventType )
protected

Registered any listener methods for the given event.

Parameters
DomainEventSource$eventSource
string$eventType
Returns
void

Definition at line 87 of file DomainEventIngress.php.

◆ registerListeners()

MediaWiki\DomainEvent\DomainEventIngress::registerListeners ( DomainEventSource $eventSource)

This default implementation of registerListeners() will automatically register a listener method for each event passed to initEvents() or initSubscriber().

The methods have to start with "handler" followed by the name of the event followed by "Event".

Stability: stable
to override

Implements MediaWiki\DomainEvent\DomainEventSubscriber.

Definition at line 153 of file DomainEventIngress.php.


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