MediaWiki master
SearchEventIngress.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Search;
4
12
20 extends DomainEventIngress
22{
23
25 public const OBJECT_SPEC = [
26 'class' => self::class,
27 'services' => [],
28 'events' => [
29 PageLatestRevisionChangedEvent::TYPE,
30 PageDeletedEvent::TYPE,
31 ],
32 ];
33
40 $newRevision = $event->getLatestRevisionAfter();
41 $mainSlot = $newRevision->isDeleted( RevisionRecord::DELETED_TEXT )
42 ? null : $newRevision->getSlot( SlotRecord::MAIN );
43
44 if (
45 $event->isModifiedSlot( SlotRecord::MAIN ) ||
46 $event->hasCause( PageLatestRevisionChangedEvent::CAUSE_MOVE ) ||
48 ) {
49 $update = new SearchUpdate(
50 $event->getPageId(),
51 $event->getPageRecordAfter(),
52 $mainSlot ? $mainSlot->getContent() : null
53 );
54
55 $update->doUpdate();
56 }
57 }
58
64 public function handlePageDeletedEvent( PageDeletedEvent $event ): void {
65 $update = new SearchUpdate(
66 $event->getPageId(),
67 $event->getDeletedPage(),
68 null
69 );
70
71 $update->doUpdate();
72 }
73
74}
Base class for event ingress objects.
isReconciliationRequest()
Determines whether this is a reconciliation event, triggered artificially in order to give listeners ...
Domain event representing page deletion.
hasCause(string $cause)
Checks whether the update had the given cause.
getPageId()
Returns the ID of the page affected by the change.
Definition PageEvent.php:87
Domain event representing a change to the page's latest revision.
getPageRecordAfter()
Returns a PageRecord representing the state of the page after the change, or null if the page no long...
isModifiedSlot(string $slotRole)
Whether the given slot was modified by the page update.
Page revision base class.
Value object representing a content slot associated with a page revision.
The ingress adapter for the search component.
handlePageLatestRevisionChangedEvent(PageLatestRevisionChangedEvent $event)
Listener method for PageLatestRevisionChangedEvent, to be registered with a DomainEventSource.
handlePageDeletedEvent(PageDeletedEvent $event)
Listener method for PageDeletedEvent, to be registered with a DomainEventSource.
const OBJECT_SPEC
Object spec intended for use with DomainEventSource::registerSubscriber().
Database independent search index updater.
doUpdate()
Perform actual update for the entry.
Listener interface for PageDeletedEvents.
Listener interface for PageLatestRevisionChangedEvents.
Definition of a mapping for the search index field.