Differential D19090 Diff 45755 src/applications/typeahead/datasource/PhabricatorTypeaheadCompositeDatasource.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/typeahead/datasource/PhabricatorTypeaheadCompositeDatasource.php
Show First 20 Lines • Show All 217 Lines • ▼ Show 20 Lines | if ($offset || $limit) { | ||||
$results = array_slice($results, $offset, $limit, $preserve_keys = true); | $results = array_slice($results, $offset, $limit, $preserve_keys = true); | ||||
} | } | ||||
return $results; | return $results; | ||||
} | } | ||||
private function getUsableDatasources() { | private function getUsableDatasources() { | ||||
if ($this->usable === null) { | if ($this->usable === null) { | ||||
$viewer = $this->getViewer(); | |||||
$sources = $this->getComponentDatasources(); | $sources = $this->getComponentDatasources(); | ||||
$extension_sources = id(new PhabricatorDatasourceEngine()) | |||||
->setViewer($viewer) | |||||
->newDatasourcesForCompositeDatasource($this); | |||||
foreach ($extension_sources as $extension_source) { | |||||
$sources[] = $extension_source; | |||||
} | |||||
$usable = array(); | $usable = array(); | ||||
foreach ($sources as $source) { | foreach ($sources as $source) { | ||||
$application_class = $source->getDatasourceApplicationClass(); | $application_class = $source->getDatasourceApplicationClass(); | ||||
if ($application_class) { | if ($application_class) { | ||||
$result = id(new PhabricatorApplicationQuery()) | $result = id(new PhabricatorApplicationQuery()) | ||||
->setViewer($this->getViewer()) | ->setViewer($this->getViewer()) | ||||
->withClasses(array($application_class)) | ->withClasses(array($application_class)) | ||||
->execute(); | ->execute(); | ||||
if (!$result) { | if (!$result) { | ||||
continue; | continue; | ||||
} | } | ||||
} | } | ||||
$source->setViewer($this->getViewer()); | $source->setViewer($viewer); | ||||
$usable[] = $source; | $usable[] = $source; | ||||
} | } | ||||
$this->usable = $usable; | $this->usable = $usable; | ||||
} | } | ||||
return $this->usable; | return $this->usable; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 70 Lines • Show Last 20 Lines |