[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/ponder/search/ -> PonderSearchIndexer.php (source)

   1  <?php
   2  
   3  final class PonderSearchIndexer
   4    extends PhabricatorSearchDocumentIndexer {
   5  
   6    public function getIndexableObject() {
   7      return new PonderQuestion();
   8    }
   9  
  10    protected function buildAbstractDocumentByPHID($phid) {
  11      $question = $this->loadDocumentByPHID($phid);
  12  
  13      $doc = $this->newDocument($phid)
  14        ->setDocumentTitle($question->getTitle())
  15        ->setDocumentCreated($question->getDateCreated())
  16        ->setDocumentModified($question->getDateModified());
  17  
  18      $doc->addField(
  19        PhabricatorSearchField::FIELD_BODY,
  20        $question->getContent());
  21  
  22      $doc->addRelationship(
  23        PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR,
  24        $question->getAuthorPHID(),
  25        PhabricatorPeopleUserPHIDType::TYPECONST,
  26        $question->getDateCreated());
  27  
  28      $answers = id(new PonderAnswerQuery())
  29        ->setViewer($this->getViewer())
  30        ->withQuestionIDs(array($question->getID()))
  31        ->execute();
  32      foreach ($answers as $answer) {
  33        if (strlen($answer->getContent())) {
  34          $doc->addField(
  35            PhabricatorSearchField::FIELD_COMMENT,
  36            $answer->getContent());
  37        }
  38      }
  39  
  40      $this->indexTransactions(
  41        $doc,
  42        new PonderQuestionTransactionQuery(),
  43        array($phid));
  44      $this->indexTransactions(
  45        $doc,
  46        new PonderAnswerTransactionQuery(),
  47        mpull($answers, 'getPHID'));
  48  
  49      return $doc;
  50    }
  51  }


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