Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/controller/DiffusionSymbolController.php
| Show All 18 Lines | protected function processDiffusionRequest(AphrontRequest $request) { | ||||
| if ($request->getStr('type')) { | if ($request->getStr('type')) { | ||||
| $query->setType($request->getStr('type')); | $query->setType($request->getStr('type')); | ||||
| } | } | ||||
| if ($request->getStr('lang')) { | if ($request->getStr('lang')) { | ||||
| $query->setLanguage($request->getStr('lang')); | $query->setLanguage($request->getStr('lang')); | ||||
| } | } | ||||
| if ($request->getStr('projects')) { | if ($request->getStr('repositories')) { | ||||
| $phids = $request->getStr('projects'); | $phids = $request->getStr('repositories'); | ||||
| $phids = explode(',', $phids); | $phids = explode(',', $phids); | ||||
| $phids = array_filter($phids); | $phids = array_filter($phids); | ||||
| if ($phids) { | if ($phids) { | ||||
| $projects = id(new PhabricatorRepositoryArcanistProject()) | $repos = id(new PhabricatorRepositoryQuery()) | ||||
| ->loadAllWhere( | ->setViewer($request->getUser()) | ||||
| 'phid IN (%Ls)', | ->withPHIDs($phids) | ||||
| $phids); | ->execute(); | ||||
| $projects = mpull($projects, 'getID'); | |||||
| if ($projects) { | $repos = mpull($repos, 'getPHID'); | ||||
| $query->setProjectIDs($projects); | if ($repos) { | ||||
| $query->withRepositoryPHIDs($repos); | |||||
epriestley: This should use RepositoryQuery and be policy-aware. | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| $query->needPaths(true); | $query->needPaths(true); | ||||
| $query->needArcanistProjects(true); | |||||
| $query->needRepositories(true); | $query->needRepositories(true); | ||||
| $symbols = $query->execute(); | $symbols = $query->execute(); | ||||
| // For PHP builtins, jump to php.net documentation. | // For PHP builtins, jump to php.net documentation. | ||||
| if ($request->getBool('jump') && count($symbols) == 0) { | if ($request->getBool('jump') && count($symbols) == 0) { | ||||
| if ($request->getStr('lang', 'php') == 'php') { | if ($request->getStr('lang', 'php') == 'php') { | ||||
| if ($request->getStr('type', 'function') == 'function') { | if ($request->getStr('type', 'function') == 'function') { | ||||
| Show All 14 Lines | if ($request->getBool('jump') && count($symbols) == 0) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| $rows = array(); | $rows = array(); | ||||
| foreach ($symbols as $symbol) { | foreach ($symbols as $symbol) { | ||||
| $project = $symbol->getArcanistProject(); | |||||
| if ($project) { | |||||
| $project_name = $project->getName(); | |||||
| } else { | |||||
| $project_name = '-'; | |||||
| } | |||||
| $file = $symbol->getPath(); | $file = $symbol->getPath(); | ||||
| $line = $symbol->getLineNumber(); | $line = $symbol->getLineNumber(); | ||||
| $repo = $symbol->getRepository(); | $repo = $symbol->getRepository(); | ||||
| if ($repo) { | if ($repo) { | ||||
| $href = $symbol->getURI(); | $href = $symbol->getURI(); | ||||
| if ($request->getBool('jump') && count($symbols) == 1) { | if ($request->getBool('jump') && count($symbols) == 1) { | ||||
| Show All 14 Lines | foreach ($symbols as $symbol) { | ||||
| $location = '?'; | $location = '?'; | ||||
| } | } | ||||
| $rows[] = array( | $rows[] = array( | ||||
| $symbol->getSymbolType(), | $symbol->getSymbolType(), | ||||
| $symbol->getSymbolContext(), | $symbol->getSymbolContext(), | ||||
| $symbol->getSymbolName(), | $symbol->getSymbolName(), | ||||
| $symbol->getSymbolLanguage(), | $symbol->getSymbolLanguage(), | ||||
| $project_name, | $repo->getMonogram(), | ||||
Done Inline ActionsConsider getMonogram() in new code to prepare for making callsigns optional eventually. epriestley: Consider getMonogram() in new code to prepare for making callsigns optional eventually. | |||||
| $location, | $location, | ||||
| ); | ); | ||||
| } | } | ||||
| $table = new AphrontTableView($rows); | $table = new AphrontTableView($rows); | ||||
| $table->setHeaders( | $table->setHeaders( | ||||
| array( | array( | ||||
| pht('Type'), | pht('Type'), | ||||
| pht('Context'), | pht('Context'), | ||||
| pht('Name'), | pht('Name'), | ||||
| pht('Language'), | pht('Language'), | ||||
| pht('Project'), | pht('Repository'), | ||||
| pht('File'), | pht('File'), | ||||
| )); | )); | ||||
| $table->setColumnClasses( | $table->setColumnClasses( | ||||
| array( | array( | ||||
| '', | '', | ||||
| '', | '', | ||||
| 'pri', | 'pri', | ||||
| '', | '', | ||||
| Show All 18 Lines | |||||
This should use RepositoryQuery and be policy-aware.