2015-06-04 23:27:48 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
final class DivinerAtomSearchIndexer extends PhabricatorSearchDocumentIndexer {
|
|
|
|
|
|
|
|
public function getIndexableObject() {
|
|
|
|
return new DivinerLiveSymbol();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function buildAbstractDocumentByPHID($phid) {
|
|
|
|
$atom = $this->loadDocumentByPHID($phid);
|
|
|
|
$book = $atom->getBook();
|
|
|
|
|
2015-06-15 22:51:51 +02:00
|
|
|
if (!$atom->getIsDocumentable()) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2015-06-04 23:27:48 +02:00
|
|
|
$doc = $this->newDocument($phid)
|
|
|
|
->setDocumentTitle($atom->getTitle())
|
|
|
|
->setDocumentCreated($book->getDateCreated())
|
|
|
|
->setDocumentModified($book->getDateModified());
|
|
|
|
|
|
|
|
$doc->addField(
|
2015-06-05 20:01:25 +02:00
|
|
|
PhabricatorSearchDocumentFieldType::FIELD_BODY,
|
2015-06-04 23:27:48 +02:00
|
|
|
$atom->getSummary());
|
|
|
|
|
|
|
|
$doc->addRelationship(
|
|
|
|
PhabricatorSearchRelationship::RELATIONSHIP_BOOK,
|
|
|
|
$atom->getBookPHID(),
|
|
|
|
DivinerBookPHIDType::TYPECONST,
|
2015-06-16 23:28:16 +02:00
|
|
|
PhabricatorTime::getNow());
|
|
|
|
|
2015-06-19 09:24:23 +02:00
|
|
|
$doc->addRelationship(
|
|
|
|
PhabricatorSearchRelationship::RELATIONSHIP_REPOSITORY,
|
|
|
|
$atom->getRepositoryPHID(),
|
|
|
|
PhabricatorRepositoryRepositoryPHIDType::TYPECONST,
|
|
|
|
PhabricatorTime::getNow());
|
|
|
|
|
2015-06-16 23:28:16 +02:00
|
|
|
$doc->addRelationship(
|
|
|
|
$atom->getGraphHash()
|
|
|
|
? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED
|
|
|
|
: PhabricatorSearchRelationship::RELATIONSHIP_OPEN,
|
|
|
|
$atom->getBookPHID(),
|
|
|
|
DivinerBookPHIDType::TYPECONST,
|
|
|
|
PhabricatorTime::getNow());
|
2015-06-04 23:27:48 +02:00
|
|
|
|
|
|
|
return $doc;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|