Changeset View
Changeset View
Standalone View
Standalone View
src/applications/search/index/PhabricatorSearchIndexer.php
<?php | <?php | ||||
final class PhabricatorSearchIndexer { | final class PhabricatorSearchIndexer { | ||||
public function queueDocumentForIndexing($phid) { | public function queueDocumentForIndexing($phid, $context = null) { | ||||
PhabricatorWorker::scheduleTask( | PhabricatorWorker::scheduleTask( | ||||
'PhabricatorSearchWorker', | 'PhabricatorSearchWorker', | ||||
array( | array( | ||||
'documentPHID' => $phid, | 'documentPHID' => $phid, | ||||
'context' => $context, | |||||
), | ), | ||||
array( | array( | ||||
'priority' => PhabricatorWorker::PRIORITY_IMPORT, | 'priority' => PhabricatorWorker::PRIORITY_IMPORT, | ||||
)); | )); | ||||
} | } | ||||
public function indexDocumentByPHID($phid) { | public function indexDocumentByPHID($phid, $context) { | ||||
$indexers = id(new PhutilSymbolLoader()) | $indexers = id(new PhutilSymbolLoader()) | ||||
->setAncestorClass('PhabricatorSearchDocumentIndexer') | ->setAncestorClass('PhabricatorSearchDocumentIndexer') | ||||
->loadObjects(); | ->loadObjects(); | ||||
foreach ($indexers as $indexer) { | foreach ($indexers as $indexer) { | ||||
if ($indexer->shouldIndexDocumentByPHID($phid)) { | if ($indexer->shouldIndexDocumentByPHID($phid)) { | ||||
$indexer->indexDocumentByPHID($phid); | $indexer->indexDocumentByPHID($phid, $context); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
return $this; | return $this; | ||||
} | } | ||||
} | } |