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 PageRevisionUpdatedEvent::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( PageRevisionUpdatedEvent::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 ) {
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.
getDeletedPage()
Returns the page that was deleted, as it was before the deletion.
Domain event representing a page update.
getLatestRevisionAfter()
The revision that became the latest as a result of the update.
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.
hasCause(string $cause)
Checks whether the update had the given cause.
getPageId()
Returns the ID of the page affected by the change.
Page revision base class.
Value object representing a content slot associated with a page revision.
The ingress adapter for the search component.
handlePageRevisionUpdatedEvent(PageRevisionUpdatedEvent $event)
Listener method for PageRevisionUpdatedEvent, 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 PageRevisionUpdatedEvents.