Differential D12530 Diff 30077 src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/typeahead/datasource/PhabricatorTypeaheadDatasource.php
Show First 20 Lines • Show All 223 Lines • ▼ Show 20 Lines | foreach ($values as $key => $value) { | ||||
} else { | } else { | ||||
$name = pht('Invalid Function: %s', $value); | $name = pht('Invalid Function: %s', $value); | ||||
$tokens[$key] = $this->newInvalidToken($name) | $tokens[$key] = $this->newInvalidToken($name) | ||||
->setKey($value); | ->setKey($value); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
// Give special non-function tokens which are also not PHIDs (like statuses | |||||
// and priorities) an opportunity to render. | |||||
$type_unknown = PhabricatorPHIDConstants::PHID_TYPE_UNKNOWN; | |||||
$special = array(); | |||||
foreach ($values as $key => $value) { | |||||
if (phid_get_type($value) == $type_unknown) { | |||||
$special[$key] = $value; | |||||
} | |||||
} | |||||
if ($special) { | |||||
$special_tokens = $this->renderSpecialTokens($special); | |||||
foreach ($special_tokens as $key => $token) { | |||||
$tokens[$key] = $token; | |||||
unset($phids[$key]); | |||||
} | |||||
} | |||||
if ($phids) { | if ($phids) { | ||||
$handles = $this->getViewer()->loadHandles($phids); | $handles = $this->getViewer()->loadHandles($phids); | ||||
foreach ($phids as $key => $phid) { | foreach ($phids as $key => $phid) { | ||||
$handle = $handles[$phid]; | $handle = $handles[$phid]; | ||||
$tokens[$key] = PhabricatorTypeaheadTokenView::newFromHandle($handle); | $tokens[$key] = PhabricatorTypeaheadTokenView::newFromHandle($handle); | ||||
} | } | ||||
} | } | ||||
Show All 20 Lines | if ($setup) { | ||||
$tokens += $function_tokens; | $tokens += $function_tokens; | ||||
} | } | ||||
} | } | ||||
return array_select_keys($tokens, array_keys($values)); | return array_select_keys($tokens, array_keys($values)); | ||||
} | } | ||||
protected function renderSpecialTokens(array $values) { | |||||
return array(); | |||||
} | |||||
/* -( Token Functions )---------------------------------------------------- */ | /* -( Token Functions )---------------------------------------------------- */ | ||||
/** | /** | ||||
* @task functions | * @task functions | ||||
*/ | */ | ||||
public function getDatasourceFunctions() { | public function getDatasourceFunctions() { | ||||
return array(); | return array(); | ||||
▲ Show 20 Lines • Show All 143 Lines • ▼ Show 20 Lines | /* -( Token Functions )---------------------------------------------------- */ | ||||
/** | /** | ||||
* @task functions | * @task functions | ||||
*/ | */ | ||||
protected function getCurrentFunction() { | protected function getCurrentFunction() { | ||||
return nonempty(last($this->functionStack), null); | return nonempty(last($this->functionStack), null); | ||||
} | } | ||||
protected function renderTokensFromResults(array $results, array $values) { | protected function renderTokensFromResults(array $results, array $values) { | ||||
$results = array_select_keys($results, $values); | |||||
$tokens = array(); | $tokens = array(); | ||||
foreach ($results as $result) { | foreach ($values as $key => $value) { | ||||
$tokens[] = PhabricatorTypeaheadTokenView::newFromTypeaheadResult( | if (empty($results[$value])) { | ||||
$result); | continue; | ||||
} | |||||
$tokens[$key] = PhabricatorTypeaheadTokenView::newFromTypeaheadResult( | |||||
$results[$value]); | |||||
} | } | ||||
return $tokens; | return $tokens; | ||||
} | } | ||||
} | } |