MediaWiki master
MediaWiki\DomainEvent\DomainEvent Class Reference

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

Inherited by MediaWiki\Page\Event\PageEvent.

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 (or "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
See also
docs/Events.md
https://www.mediawiki.org/wiki/Manual:Domain_events

Definition at line 33 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 48 of file DomainEvent.php.

References MediaWiki\DomainEvent\DomainEvent\isReconciliationRequest().

Member Function Documentation

◆ declareEventType()

◆ getEventTimestamp()

MediaWiki\DomainEvent\DomainEvent::getEventTimestamp ( )

Returns the time at which the event was emitted.

Definition at line 110 of file DomainEvent.php.

◆ getEventType()

MediaWiki\DomainEvent\DomainEvent::getEventType ( )

Returns this event's type.

Definition at line 82 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 98 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 64 of file DomainEvent.php.

Referenced by MediaWiki\DomainEvent\DomainEvent\__construct().

Member Data Documentation

◆ ANY

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

Definition at line 35 of file DomainEvent.php.


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