Changeset View
Changeset View
Standalone View
Standalone View
src/applications/search/index/PhabricatorSearchDocumentIndexer.php
<?php | <?php | ||||
abstract class PhabricatorSearchDocumentIndexer extends Phobject { | abstract class PhabricatorSearchDocumentIndexer extends Phobject { | ||||
private $context; | |||||
protected function setContext($context) { | |||||
$this->context = $context; | |||||
return $this; | |||||
} | |||||
protected function getContext() { | |||||
return $this->context; | |||||
} | |||||
abstract public function getIndexableObject(); | abstract public function getIndexableObject(); | ||||
abstract protected function buildAbstractDocumentByPHID($phid); | abstract protected function buildAbstractDocumentByPHID($phid); | ||||
protected function getViewer() { | protected function getViewer() { | ||||
return PhabricatorUser::getOmnipotentUser(); | return PhabricatorUser::getOmnipotentUser(); | ||||
} | } | ||||
public function shouldIndexDocumentByPHID($phid) { | public function shouldIndexDocumentByPHID($phid) { | ||||
Show All 12 Lines | $object = id(new PhabricatorObjectQuery()) | ||||
->withPHIDs(array($phid)) | ->withPHIDs(array($phid)) | ||||
->executeOne(); | ->executeOne(); | ||||
if (!$object) { | if (!$object) { | ||||
throw new Exception(pht("Unable to load object by PHID '%s'!", $phid)); | throw new Exception(pht("Unable to load object by PHID '%s'!", $phid)); | ||||
} | } | ||||
return $object; | return $object; | ||||
} | } | ||||
public function indexDocumentByPHID($phid, $context) { | public function indexDocumentByPHID($phid) { | ||||
$this->setContext($context); | |||||
$document = $this->buildAbstractDocumentByPHID($phid); | $document = $this->buildAbstractDocumentByPHID($phid); | ||||
if ($document === null) { | if ($document === null) { | ||||
// This indexer doesn't build a document index, so we're done. | // This indexer doesn't build a document index, so we're done. | ||||
return $this; | return $this; | ||||
} | } | ||||
$object = $this->loadDocumentByPHID($phid); | $object = $this->loadDocumentByPHID($phid); | ||||
Show All 24 Lines |