1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-28 17:52:43 +01:00
phorge-phorge/src/applications/diviner/search/DivinerAtomSearchIndexer.php
Joshua Spence 69d12f64ba Add repositories to Diviner
Summary: Fixes T8352. Associate Diviner books and atoms with a repository. This relationship is not really surfaced anywhere in the UI but provides metadata that contextualises search results. Depends on D13091.

Test Plan: Ran `diviner generate --repository ARC` and then went to `/diviner/book/arcanist/`.

Reviewers: #blessed_reviewers, epriestley

Reviewed By: #blessed_reviewers, epriestley

Subscribers: Korvin, epriestley

Maniphest Tasks: T7703, T8352

Differential Revision: https://secure.phabricator.com/D13070
2015-06-19 17:52:28 +10:00

49 lines
1.3 KiB
PHP

<?php
final class DivinerAtomSearchIndexer extends PhabricatorSearchDocumentIndexer {
public function getIndexableObject() {
return new DivinerLiveSymbol();
}
protected function buildAbstractDocumentByPHID($phid) {
$atom = $this->loadDocumentByPHID($phid);
$book = $atom->getBook();
if (!$atom->getIsDocumentable()) {
return null;
}
$doc = $this->newDocument($phid)
->setDocumentTitle($atom->getTitle())
->setDocumentCreated($book->getDateCreated())
->setDocumentModified($book->getDateModified());
$doc->addField(
PhabricatorSearchDocumentFieldType::FIELD_BODY,
$atom->getSummary());
$doc->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_BOOK,
$atom->getBookPHID(),
DivinerBookPHIDType::TYPECONST,
PhabricatorTime::getNow());
$doc->addRelationship(
PhabricatorSearchRelationship::RELATIONSHIP_REPOSITORY,
$atom->getRepositoryPHID(),
PhabricatorRepositoryRepositoryPHIDType::TYPECONST,
PhabricatorTime::getNow());
$doc->addRelationship(
$atom->getGraphHash()
? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED
: PhabricatorSearchRelationship::RELATIONSHIP_OPEN,
$atom->getBookPHID(),
DivinerBookPHIDType::TYPECONST,
PhabricatorTime::getNow());
return $doc;
}
}