diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index c08e44ca31..457be534e8 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1493,6 +1493,7 @@ phutil_register_library_map(array( 'PhabricatorCalendarEventPHIDType' => 'applications/calendar/phid/PhabricatorCalendarEventPHIDType.php', 'PhabricatorCalendarEventQuery' => 'applications/calendar/query/PhabricatorCalendarEventQuery.php', 'PhabricatorCalendarEventSearchEngine' => 'applications/calendar/query/PhabricatorCalendarEventSearchEngine.php', + 'PhabricatorCalendarEventSearchIndexer' => 'applications/calendar/search/PhabricatorCalendarEventSearchIndexer.php', 'PhabricatorCalendarEventTransaction' => 'applications/calendar/storage/PhabricatorCalendarEventTransaction.php', 'PhabricatorCalendarEventTransactionComment' => 'applications/calendar/storage/PhabricatorCalendarEventTransactionComment.php', 'PhabricatorCalendarEventTransactionQuery' => 'applications/calendar/query/PhabricatorCalendarEventTransactionQuery.php', @@ -4830,6 +4831,7 @@ phutil_register_library_map(array( 'PhabricatorCalendarEventPHIDType' => 'PhabricatorPHIDType', 'PhabricatorCalendarEventQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'PhabricatorCalendarEventSearchEngine' => 'PhabricatorApplicationSearchEngine', + 'PhabricatorCalendarEventSearchIndexer' => 'PhabricatorSearchDocumentIndexer', 'PhabricatorCalendarEventTransaction' => 'PhabricatorApplicationTransaction', 'PhabricatorCalendarEventTransactionComment' => 'PhabricatorApplicationTransactionComment', 'PhabricatorCalendarEventTransactionQuery' => 'PhabricatorApplicationTransactionQuery', diff --git a/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php b/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php index 2046e746c7..ea8b006ffd 100644 --- a/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php +++ b/src/applications/calendar/editor/PhabricatorCalendarEventEditor.php @@ -215,4 +215,8 @@ final class PhabricatorCalendarEventEditor array $xactions) { return true; } + + protected function supportsSearch() { + return true; + } } diff --git a/src/applications/calendar/search/PhabricatorCalendarEventSearchIndexer.php b/src/applications/calendar/search/PhabricatorCalendarEventSearchIndexer.php new file mode 100644 index 0000000000..696e78accd --- /dev/null +++ b/src/applications/calendar/search/PhabricatorCalendarEventSearchIndexer.php @@ -0,0 +1,52 @@ +loadDocumentByPHID($phid); + + $doc = new PhabricatorSearchAbstractDocument(); + $doc->setPHID($event->getPHID()); + $doc->setDocumentType(PhabricatorCalendarEventPHIDType::TYPECONST); + $doc->setDocumentTitle($event->getName()); + $doc->setDocumentCreated($event->getDateCreated()); + $doc->setDocumentModified($event->getDateModified()); + + $doc->addField( + PhabricatorSearchField::FIELD_BODY, + $event->getDescription()); + + $doc->addRelationship( + PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, + $event->getUserPHID(), + PhabricatorPeopleUserPHIDType::TYPECONST, + $event->getDateCreated()); + + $doc->addRelationship( + PhabricatorSearchRelationship::RELATIONSHIP_OWNER, + $event->getUserPHID(), + PhabricatorPeopleUserPHIDType::TYPECONST, + $event->getDateCreated()); + + $doc->addRelationship( + $event->getIsCancelled() + ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED + : PhabricatorSearchRelationship::RELATIONSHIP_OPEN, + $event->getPHID(), + PhabricatorCalendarEventPHIDType::TYPECONST, + time()); + + $this->indexTransactions( + $doc, + new PhabricatorCalendarEventTransactionQuery(), + array($phid)); + + return $doc; + } + +}