MediaWiki master
SearchEventIngress.php
Go to the documentation of this file.
1<?php
2
3namespace MediaWiki\Search;
4
9
17
19 public const OBJECT_SPEC = [
20 'class' => self::class,
21 'services' => [],
22 'events' => [
23 PageUpdatedEvent::TYPE
24 ],
25 ];
26
33 $newRevision = $event->getNewRevision();
34 $mainSlot = $newRevision->getSlot( SlotRecord::MAIN );
35 if (
36 ( $event->isModifiedSlot( SlotRecord::MAIN )
37 || $event->hasFlag( PageUpdatedEvent::FLAG_MOVED ) ) &&
38 !$newRevision->isDeleted( RevisionRecord::DELETED_TEXT )
39 ) {
40 // NOTE: no need to go through DeferredUpdates,
41 // we are already deferred.
42 $update = new SearchUpdate(
43 $event->getPage()->getId(),
44 $event->getPage(),
45 $mainSlot->getContent()
46 );
47
48 // No need to schedule a DeferredUpdate, listeners use deferred
49 // delivery anyway.
50 $update->doUpdate();
51 }
52 }
53
54}
Base class for classes that implement DomainEventSubscriber.
Page revision base class.
Value object representing a content slot associated with a page revision.
The ingres adapter for the search component.
handlePageUpdatedEventAfterCommit(PageUpdatedEvent $event)
Listener method for PageUpdatedEvent, to be registered with a DomainEventSource.
const OBJECT_SPEC
Object spec intented for use with DomainEventSource::registerSubscriber().
Database independent search index updater.
Domain event representing a page edit.
hasFlag(string $name)
Checks flags describing the page update.
getPage()
Returns the page that was edited.
isModifiedSlot(string $slotRole)
Whether the given slot was modified by the edit.
getNewRevision()
The revision that became the current one because of the edit.