[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/repository/search/ -> PhabricatorRepositoryCommitSearchIndexer.php (source)

   1  <?php
   2  
   3  final class PhabricatorRepositoryCommitSearchIndexer
   4    extends PhabricatorSearchDocumentIndexer {
   5  
   6    public function getIndexableObject() {
   7      return new PhabricatorRepositoryCommit();
   8    }
   9  
  10    protected function buildAbstractDocumentByPHID($phid) {
  11      $commit = $this->loadDocumentByPHID($phid);
  12  
  13      $commit_data = id(new PhabricatorRepositoryCommitData())->loadOneWhere(
  14        'commitID = %d',
  15        $commit->getID());
  16      $date_created = $commit->getEpoch();
  17      $commit_message = $commit_data->getCommitMessage();
  18      $author_phid = $commit_data->getCommitDetail('authorPHID');
  19  
  20      $repository = id(new PhabricatorRepositoryQuery())
  21        ->setViewer($this->getViewer())
  22        ->withIDs(array($commit->getRepositoryID()))
  23        ->executeOne();
  24      if (!$repository) {
  25        throw new Exception('No such repository!');
  26      }
  27  
  28      $title = 'r'.$repository->getCallsign().$commit->getCommitIdentifier().
  29        ' '.$commit_data->getSummary();
  30  
  31      $doc = new PhabricatorSearchAbstractDocument();
  32      $doc->setPHID($commit->getPHID());
  33      $doc->setDocumentType(PhabricatorRepositoryCommitPHIDType::TYPECONST);
  34      $doc->setDocumentCreated($date_created);
  35      $doc->setDocumentModified($date_created);
  36      $doc->setDocumentTitle($title);
  37  
  38      $doc->addField(
  39        PhabricatorSearchField::FIELD_BODY,
  40        $commit_message);
  41  
  42      if ($author_phid) {
  43        $doc->addRelationship(
  44          PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR,
  45          $author_phid,
  46          PhabricatorPeopleUserPHIDType::TYPECONST,
  47          $date_created);
  48      }
  49  
  50      $doc->addRelationship(
  51        PhabricatorSearchRelationship::RELATIONSHIP_REPOSITORY,
  52        $repository->getPHID(),
  53        PhabricatorRepositoryRepositoryPHIDType::TYPECONST,
  54        $date_created);
  55  
  56      $this->indexTransactions(
  57        $doc,
  58        new PhabricatorAuditTransactionQuery(),
  59        array($commit->getPHID()));
  60  
  61      return $doc;
  62    }
  63  }


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