MediaWiki master
|
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.
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. | |
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.
Definition at line 44 of file DomainEventIngress.php.
|
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.
Definition at line 136 of file DomainEventIngress.php.
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:
array | $options | the object spec describing the subscriber, typically from extension.json. |
Implements MediaWiki\DomainEvent\InitializableDomainEventSubscriber.
Definition at line 64 of file DomainEventIngress.php.
|
protected |
Registered any listener methods for the given event.
DomainEventSource | $eventSource | |
string | $eventType |
Definition at line 87 of file DomainEventIngress.php.
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".
Implements MediaWiki\DomainEvent\DomainEventSubscriber.
Definition at line 153 of file DomainEventIngress.php.