MediaWiki master
LanguageEventIngress.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Languages;
4
9
17
18 private MessageCache $messageCache;
19
21 public const OBJECT_SPEC = [
22 'class' => self::class,
23 'services' => [
24 'MessageCache'
25 ],
26 'events' => [
27 PageUpdatedEvent::TYPE
28 ],
29 ];
30
31 public function __construct( MessageCache $messageCache ) {
32 $this->messageCache = $messageCache;
33 }
34
41 if ( $event->getPage()->getNamespace() === NS_MEDIAWIKI &&
42 ( $event->isModifiedSlot( SlotRecord::MAIN )
43 || $event->hasCause( PageUpdatedEvent::CAUSE_MOVE ) )
44 ) {
45 $content = $event->getNewRevision()->getMainContentRaw();
46 $this->messageCache->updateMessageOverride( $event->getPage(), $content );
47 }
48 }
49
50}
const NS_MEDIAWIKI
Definition Defines.php:73
Base class for classes that implement DomainEventSubscriber.
The ingress adapter for the language component.
const OBJECT_SPEC
Object spec intended for use with DomainEventSource::registerSubscriber().
handlePageUpdatedEventAfterCommit(PageUpdatedEvent $event)
Listener method for PageUpdatedEvent, to be registered with a DomainEventSource.
getPage()
Returns the page that was edited.
Definition PageEvent.php:90
hasCause(string $cause)
Checks whether the update had the given cause.
Domain event representing a page edit.
isModifiedSlot(string $slotRole)
Whether the given slot was modified by the edit.
getNewRevision()
The revision that became the current one because of the edit.
Value object representing a content slot associated with a page revision.
Cache messages that are defined by MediaWiki-namespace pages or by hooks.