[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/src/applications/fund/search/ -> FundInitiativeIndexer.php (source)

   1  <?php
   2  
   3  final class FundInitiativeIndexer
   4    extends PhabricatorSearchDocumentIndexer {
   5  
   6    public function getIndexableObject() {
   7      return new FundInitiative();
   8    }
   9  
  10    protected function loadDocumentByPHID($phid) {
  11      $object = id(new FundInitiativeQuery())
  12        ->setViewer($this->getViewer())
  13        ->withPHIDs(array($phid))
  14        ->executeOne();
  15      if (!$object) {
  16        throw new Exception("Unable to load object by phid '{$phid}'!");
  17      }
  18      return $object;
  19    }
  20  
  21    protected function buildAbstractDocumentByPHID($phid) {
  22      $initiative = $this->loadDocumentByPHID($phid);
  23  
  24      $doc = id(new PhabricatorSearchAbstractDocument())
  25        ->setPHID($initiative->getPHID())
  26        ->setDocumentType(FundInitiativePHIDType::TYPECONST)
  27        ->setDocumentTitle($initiative->getName())
  28        ->setDocumentCreated($initiative->getDateCreated())
  29        ->setDocumentModified($initiative->getDateModified());
  30  
  31      $doc->addRelationship(
  32        PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR,
  33        $initiative->getOwnerPHID(),
  34        PhabricatorPeopleUserPHIDType::TYPECONST,
  35        $initiative->getDateCreated());
  36  
  37      $doc->addRelationship(
  38        PhabricatorSearchRelationship::RELATIONSHIP_OWNER,
  39        $initiative->getOwnerPHID(),
  40        PhabricatorPeopleUserPHIDType::TYPECONST,
  41        $initiative->getDateCreated());
  42  
  43      $doc->addRelationship(
  44        $initiative->isClosed()
  45          ? PhabricatorSearchRelationship::RELATIONSHIP_CLOSED
  46          : PhabricatorSearchRelationship::RELATIONSHIP_OPEN,
  47        $initiative->getPHID(),
  48        FundInitiativePHIDType::TYPECONST,
  49        time());
  50  
  51      $this->indexTransactions(
  52        $doc,
  53        new FundInitiativeTransactionQuery(),
  54        array($initiative->getPHID()));
  55  
  56      return $doc;
  57    }
  58  }


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