[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/phriction/search/ -> PhrictionSearchIndexer.php (source)

   1  <?php
   2  
   3  final class PhrictionSearchIndexer
   4    extends PhabricatorSearchDocumentIndexer {
   5  
   6    public function getIndexableObject() {
   7      return new PhrictionDocument();
   8    }
   9  
  10    protected function buildAbstractDocumentByPHID($phid) {
  11      $document = $this->loadDocumentByPHID($phid);
  12  
  13      $content = id(new PhrictionContent())->load($document->getContentID());
  14      $document->attachContent($content);
  15  
  16      $content = $document->getContent();
  17  
  18      $doc = new PhabricatorSearchAbstractDocument();
  19      $doc->setPHID($document->getPHID());
  20      $doc->setDocumentType(PhrictionDocumentPHIDType::TYPECONST);
  21      $doc->setDocumentTitle($content->getTitle());
  22  
  23      // TODO: This isn't precisely correct, denormalize into the Document table?
  24      $doc->setDocumentCreated($content->getDateCreated());
  25      $doc->setDocumentModified($content->getDateModified());
  26  
  27      $doc->addField(
  28        PhabricatorSearchField::FIELD_BODY,
  29        $content->getContent());
  30  
  31      $doc->addRelationship(
  32        PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR,
  33        $content->getAuthorPHID(),
  34        PhabricatorPeopleUserPHIDType::TYPECONST,
  35        $content->getDateCreated());
  36  
  37      $doc->addRelationship(
  38        ($document->getStatus() == PhrictionDocumentStatus::STATUS_EXISTS)
  39          ? PhabricatorSearchRelationship::RELATIONSHIP_OPEN
  40          : PhabricatorSearchRelationship::RELATIONSHIP_CLOSED,
  41        $document->getPHID(),
  42        PhrictionDocumentPHIDType::TYPECONST,
  43        time());
  44  
  45      return $doc;
  46    }
  47  }


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1