MediaWiki master
MediaWiki\DomainEvent\DomainEvent Class Reference

Base class for domain event objects to be used with DomainEventDispatcher. More...

Inherited by MediaWiki\Page\Event\PageStateEvent.

Public Member Functions

 __construct ( $timestamp=false, bool $isReconciliationRequest=false)
 
 getEventTimestamp ()
 Returns the time at which the event was emitted.
 
 getEventType ()
 Returns this event's type.
 
 getEventTypeChain ()
 Returns the event types this event is compatible with.
 
 isReconciliationRequest ()
 Determines whether this is a reconciliation event, triggered artificially in order to give listeners an opportunity to catch up on missed events or recreate corrupted data.
 

Public Attributes

const ANY = '*'
 

Protected Member Functions

 declareEventType (string $eventType)
 Declares the event type.
 

Detailed Description

Base class for domain event objects to be used with DomainEventDispatcher.

Domain events are used to notify other parts of the code (oder "domains") about a change to the persistent state of the local wiki.

The idea of domain events is borrowed from the Domain Driven Design paradigm. For a thorough explanation, see https://learn.microsoft.com/en-us/dotnet/architecture/microservices/microservice-ddd-cqrs-patterns/domain-events-design-implementation. Also compare https://martinfowler.com/eaaDev/DomainEvent.html.

Domain event objects must be immutable.

An event object should contain all information that was used to affect that change (the command parameters) as well as information representing the outcome of the change.

Note
Subclasses must call declareEventType() in their constructor!
Since
1.44
Stability: unstable
until 1.45, should become stable to extend

Definition at line 31 of file DomainEvent.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\DomainEvent\DomainEvent::__construct ( $timestamp = false,
bool $isReconciliationRequest = false )
Stability: stable
to call
Parameters
string | ConvertibleTimestamp | false$timestamp
bool$isReconciliationRequestsee isReconciliationRequest()

Definition at line 46 of file DomainEvent.php.

References MediaWiki\DomainEvent\DomainEvent\isReconciliationRequest().

Member Function Documentation

◆ declareEventType()

MediaWiki\DomainEvent\DomainEvent::declareEventType ( string $eventType)
protected

Declares the event type.

Must be called from the constructors of all subclasses of DomainEvent!

Parameters
string$eventType

Definition at line 72 of file DomainEvent.php.

Referenced by MediaWiki\Page\Event\PageMovedEvent\__construct(), MediaWiki\Page\Event\PageDeletedEvent\__construct(), MediaWiki\Page\Event\PageStateEvent\__construct(), and MediaWiki\Page\Event\PageRevisionUpdatedEvent\__construct().

◆ getEventTimestamp()

MediaWiki\DomainEvent\DomainEvent::getEventTimestamp ( )

Returns the time at which the event was emitted.

Definition at line 108 of file DomainEvent.php.

◆ getEventType()

MediaWiki\DomainEvent\DomainEvent::getEventType ( )

Returns this event's type.

Definition at line 80 of file DomainEvent.php.

◆ getEventTypeChain()

MediaWiki\DomainEvent\DomainEvent::getEventTypeChain ( )

Returns the event types this event is compatible with.

Access: internal
for use in EventDispatchEngine.
Returns
array An array containing the event's type and all parent types.

Definition at line 96 of file DomainEvent.php.

◆ isReconciliationRequest()

MediaWiki\DomainEvent\DomainEvent::isReconciliationRequest ( )

Determines whether this is a reconciliation event, triggered artificially in order to give listeners an opportunity to catch up on missed events or recreate corrupted data.

Reconciliation requests are typically issued by maintenance scripts, but can also be caused by user actions such as null-edits.

Definition at line 62 of file DomainEvent.php.

Referenced by MediaWiki\DomainEvent\DomainEvent\__construct(), MediaWiki\Languages\LanguageEventIngress\handlePageRevisionUpdatedEvent(), and MediaWiki\Search\SearchEventIngress\handlePageRevisionUpdatedEvent().

Member Data Documentation

◆ ANY

const MediaWiki\DomainEvent\DomainEvent::ANY = '*'

Definition at line 33 of file DomainEvent.php.


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