Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/typeahead/DiffusionSymbolDatasource.php
| Show All 26 Lines | public function loadResults() { | ||||
| $results = array(); | $results = array(); | ||||
| if (strlen($raw_query)) { | if (strlen($raw_query)) { | ||||
| $symbols = id(new DiffusionSymbolQuery()) | $symbols = id(new DiffusionSymbolQuery()) | ||||
| ->setViewer($viewer) | ->setViewer($viewer) | ||||
| ->setNamePrefix($raw_query) | ->setNamePrefix($raw_query) | ||||
| ->setLimit(15) | ->setLimit(15) | ||||
| ->needArcanistProjects(true) | |||||
| ->needRepositories(true) | ->needRepositories(true) | ||||
| ->needPaths(true) | ->needPaths(true) | ||||
| ->execute(); | ->execute(); | ||||
| foreach ($symbols as $symbol) { | foreach ($symbols as $symbol) { | ||||
| $lang = $symbol->getSymbolLanguage(); | $lang = $symbol->getSymbolLanguage(); | ||||
| $name = $symbol->getSymbolName(); | $name = $symbol->getSymbolName(); | ||||
| $type = $symbol->getSymbolType(); | $type = $symbol->getSymbolType(); | ||||
| $proj = $symbol->getArcanistProject()->getName(); | $repo = $symbol->getRepository()->getName(); | ||||
| $results[] = id(new PhabricatorTypeaheadResult()) | $results[] = id(new PhabricatorTypeaheadResult()) | ||||
| ->setName($name) | ->setName($name) | ||||
| ->setURI($symbol->getURI()) | ->setURI($symbol->getURI()) | ||||
| ->setPHID(md5($symbol->getURI())) // Just needs to be unique. | ->setPHID(md5($symbol->getURI())) // Just needs to be unique. | ||||
| ->setDisplayName($name) | ->setDisplayName($name) | ||||
| ->setDisplayType(strtoupper($lang).' '.ucwords($type).' ('.$proj.')') | ->setDisplayType(strtoupper($lang).' '.ucwords($type).' ('.$repo.')') | ||||
| ->setPriorityType('symb'); | ->setPriorityType('symb'); | ||||
| } | } | ||||
| } | } | ||||
| return $results; | return $results; | ||||
| } | } | ||||
| } | } | ||||