Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / repository / search / DiffusionCommitFulltextEngine.php
blob640cf03f43d8aa96d4ee33022d164594d1b21a0c
1 <?php
3 final class DiffusionCommitFulltextEngine
4 extends PhabricatorFulltextEngine {
6 protected function buildAbstractDocument(
7 PhabricatorSearchAbstractDocument $document,
8 $object) {
10 $commit = id(new DiffusionCommitQuery())
11 ->setViewer($this->getViewer())
12 ->withPHIDs(array($object->getPHID()))
13 ->needCommitData(true)
14 ->executeOne();
16 $repository = $commit->getRepository();
17 $commit_data = $commit->getCommitData();
19 $date_created = $commit->getEpoch();
20 $commit_message = $commit_data->getCommitMessage();
21 $author_phid = $commit_data->getCommitDetail('authorPHID');
23 $monogram = $commit->getMonogram();
24 $summary = $commit_data->getSummary();
26 $title = "{$monogram} {$summary}";
28 $document
29 ->setDocumentCreated($date_created)
30 ->setDocumentModified($date_created)
31 ->setDocumentTitle($title);
33 $document->addField(
34 PhabricatorSearchDocumentFieldType::FIELD_BODY,
35 $commit_message);
37 if ($author_phid) {
38 $document->addRelationship(
39 PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR,
40 $author_phid,
41 PhabricatorPeopleUserPHIDType::TYPECONST,
42 $date_created);
45 $document->addRelationship(
46 PhabricatorSearchRelationship::RELATIONSHIP_REPOSITORY,
47 $repository->getPHID(),
48 PhabricatorRepositoryRepositoryPHIDType::TYPECONST,
49 $date_created);
51 $document->addRelationship(
52 $commit->isUnreachable()
53 ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED
54 : PhabricatorSearchRelationship::RELATIONSHIP_OPEN,
55 $commit->getPHID(),
56 PhabricatorRepositoryCommitPHIDType::TYPECONST,
57 PhabricatorTime::getNow());