Differential D12458 Diff 29954 src/applications/typeahead/datasource/PhabricatorTypeaheadCompositeDatasource.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/typeahead/datasource/PhabricatorTypeaheadCompositeDatasource.php
Show All 19 Lines | abstract class PhabricatorTypeaheadCompositeDatasource | ||||
public function getDatasourceApplicationClass() { | public function getDatasourceApplicationClass() { | ||||
return null; | return null; | ||||
} | } | ||||
public function loadResults() { | public function loadResults() { | ||||
$offset = $this->getOffset(); | $offset = $this->getOffset(); | ||||
$limit = $this->getLimit(); | $limit = $this->getLimit(); | ||||
// If the input query is a function like `members(platy`, and we can | |||||
// parse the function, we strip the function off and hand the stripped | |||||
// query to child sources. This makes it easier to implement function | |||||
// sources in terms of real object sources. | |||||
$raw_query = $this->getRawQuery(); | |||||
if (self::isFunctionToken($raw_query)) { | |||||
$function = $this->parseFunction($raw_query, $allow_partial = true); | |||||
if ($function) { | |||||
$raw_query = head($function['argv']); | |||||
} | |||||
} | |||||
$results = array(); | $results = array(); | ||||
foreach ($this->getUsableDatasources() as $source) { | foreach ($this->getUsableDatasources() as $source) { | ||||
$source | $source | ||||
->setRawQuery($this->getRawQuery()) | ->setRawQuery($raw_query) | ||||
->setQuery($this->getQuery()) | ->setQuery($this->getQuery()) | ||||
->setViewer($this->getViewer()); | ->setViewer($this->getViewer()); | ||||
if ($limit) { | if ($limit) { | ||||
$source->setLimit($offset + $limit); | $source->setLimit($offset + $limit); | ||||
} | } | ||||
$results[] = $source->loadResults(); | $source_results = $source->loadResults(); | ||||
$source_results = $source->didLoadResults($source_results); | |||||
$results[] = $source_results; | |||||
} | } | ||||
$results = array_mergev($results); | $results = array_mergev($results); | ||||
$results = msort($results, 'getSortKey'); | $results = msort($results, 'getSortKey'); | ||||
$count = count($results); | $count = count($results); | ||||
if ($offset || $limit) { | if ($offset || $limit) { | ||||
if (!$limit) { | if (!$limit) { | ||||
▲ Show 20 Lines • Show All 70 Lines • Show Last 20 Lines |