Path: blob/master/src/applications/diffusion/conduit/DiffusionFindSymbolsConduitAPIMethod.php
12242 views
<?php12final class DiffusionFindSymbolsConduitAPIMethod3extends DiffusionConduitAPIMethod {45public function getAPIMethodName() {6return 'diffusion.findsymbols';7}89public function getMethodDescription() {10return pht('Retrieve Diffusion symbol information.');11}1213protected function defineParamTypes() {14return array(15'name' => 'optional string',16'namePrefix' => 'optional string',17'context' => 'optional string',18'language' => 'optional string',19'type' => 'optional string',20'repositoryPHID' => 'optional string',21);22}2324protected function defineReturnType() {25return 'nonempty list<dict>';26}2728protected function execute(ConduitAPIRequest $request) {29$name = $request->getValue('name');30$name_prefix = $request->getValue('namePrefix');31$context = $request->getValue('context');32$language = $request->getValue('language');33$type = $request->getValue('type');34$repository = $request->getValue('repositoryPHID');3536$query = id(new DiffusionSymbolQuery())37->setViewer($request->getUser());38if ($name !== null) {39$query->setName($name);40}41if ($name_prefix !== null) {42$query->setNamePrefix($name_prefix);43}44if ($context !== null) {45$query->setContext($context);46}47if ($language !== null) {48$query->setLanguage($language);49}50if ($type !== null) {51$query->setType($type);52}53if ($repository !== null) {54$query->withRepositoryPHIDs(array($repository));55}5657$query->needPaths(true);58$query->needRepositories(true);5960$results = $query->execute();616263$response = array();64foreach ($results as $result) {65$uri = $result->getURI();66if ($uri) {67$uri = PhabricatorEnv::getProductionURI($uri);68}6970$response[] = array(71'name' => $result->getSymbolName(),72'context' => $result->getSymbolContext(),73'type' => $result->getSymbolType(),74'language' => $result->getSymbolLanguage(),75'path' => $result->getPath(),76'line' => $result->getLineNumber(),77'uri' => $uri,78'repositoryPHID' => $result->getRepository()->getPHID(),79);80}8182return $response;83}8485}868788