mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-23 21:18:19 +01:00
fe294d4034
Summary: Depends on D19089. Fixes T13079. This is likely not the final form of this, but creates a defensible extension point. Test Plan: See T13079 for discussion. Maniphest Tasks: T13079 Differential Revision: https://secure.phabricator.com/D19090
55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
<?php
|
|
|
|
final class PhabricatorDatasourceEngine extends Phobject {
|
|
|
|
private $viewer;
|
|
|
|
public function setViewer(PhabricatorUser $viewer) {
|
|
$this->viewer = $viewer;
|
|
return $this;
|
|
}
|
|
|
|
public function getViewer() {
|
|
return $this->viewer;
|
|
}
|
|
|
|
public function getAllQuickSearchDatasources() {
|
|
return PhabricatorDatasourceEngineExtension::getAllQuickSearchDatasources();
|
|
}
|
|
|
|
public function newJumpURI($query) {
|
|
$viewer = $this->getViewer();
|
|
$extensions = PhabricatorDatasourceEngineExtension::getAllExtensions();
|
|
|
|
foreach ($extensions as $extension) {
|
|
$jump_uri = id(clone $extension)
|
|
->setViewer($viewer)
|
|
->newJumpURI($query);
|
|
|
|
if ($jump_uri !== null) {
|
|
return $jump_uri;
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public function newDatasourcesForCompositeDatasource(
|
|
PhabricatorTypeaheadCompositeDatasource $datasource) {
|
|
$viewer = $this->getViewer();
|
|
$extensions = PhabricatorDatasourceEngineExtension::getAllExtensions();
|
|
|
|
$sources = array();
|
|
foreach ($extensions as $extension) {
|
|
$extension_sources = id(clone $extension)
|
|
->setViewer($viewer)
|
|
->newDatasourcesForCompositeDatasource($datasource);
|
|
foreach ($extension_sources as $extension_source) {
|
|
$sources[] = $extension_source;
|
|
}
|
|
}
|
|
|
|
return $sources;
|
|
}
|
|
|
|
}
|