2011-12-21 18:39:33 +01:00
|
|
|
<?php
|
|
|
|
|
Rename Conduit classes
Summary: Ref T5655. Rename Conduit classes and provide a `getAPIMethodName` method to declare the API method.
Test Plan:
```
> echo '{}' | arc --conduit-uri='http://phabricator.joshuaspence.com' call-conduit user.whoami
Waiting for JSON parameters on stdin...
{"error":null,"errorMessage":null,"response":{"phid":"PHID-USER-lioqffnwn6y475mu5ndb","userName":"josh","realName":"Joshua Spence","image":"http:\/\/phabricator.joshuaspence.com\/res\/1404425321T\/phabricator\/3eb28cd9\/rsrc\/image\/avatar.png","uri":"http:\/\/phabricator.joshuaspence.com\/p\/josh\/","roles":["admin","verified","approved","activated"]}}
```
Reviewers: epriestley, #blessed_reviewers
Reviewed By: epriestley, #blessed_reviewers
Subscribers: epriestley, Korvin, hach-que
Maniphest Tasks: T5655
Differential Revision: https://secure.phabricator.com/D9991
2014-07-25 02:54:15 +02:00
|
|
|
final class DiffusionFindSymbolsConduitAPIMethod
|
|
|
|
extends DiffusionConduitAPIMethod {
|
|
|
|
|
|
|
|
public function getAPIMethodName() {
|
|
|
|
return 'diffusion.findsymbols';
|
|
|
|
}
|
2011-12-21 18:39:33 +01:00
|
|
|
|
|
|
|
public function getMethodDescription() {
|
2014-06-09 20:36:49 +02:00
|
|
|
return 'Retrieve Diffusion symbol information.';
|
2011-12-21 18:39:33 +01:00
|
|
|
}
|
|
|
|
|
2015-04-13 00:59:07 +02:00
|
|
|
protected function defineParamTypes() {
|
2011-12-21 18:39:33 +01:00
|
|
|
return array(
|
|
|
|
'name' => 'optional string',
|
|
|
|
'namePrefix' => 'optional string',
|
2012-08-07 18:29:34 +02:00
|
|
|
'context' => 'optional string',
|
2011-12-21 18:39:33 +01:00
|
|
|
'language' => 'optional string',
|
|
|
|
'type' => 'optional string',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-04-13 00:59:07 +02:00
|
|
|
protected function defineReturnType() {
|
2011-12-21 18:39:33 +01:00
|
|
|
return 'nonempty list<dict>';
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function execute(ConduitAPIRequest $request) {
|
|
|
|
$name = $request->getValue('name');
|
|
|
|
$name_prefix = $request->getValue('namePrefix');
|
2012-08-07 18:29:34 +02:00
|
|
|
$context = $request->getValue('context');
|
2011-12-21 18:39:33 +01:00
|
|
|
$language = $request->getValue('language');
|
|
|
|
$type = $request->getValue('type');
|
|
|
|
|
2015-02-01 03:36:36 +01:00
|
|
|
$query = id(new DiffusionSymbolQuery())
|
|
|
|
->setViewer($request->getUser());
|
2011-12-21 18:39:33 +01:00
|
|
|
if ($name !== null) {
|
|
|
|
$query->setName($name);
|
|
|
|
}
|
|
|
|
if ($name_prefix !== null) {
|
|
|
|
$query->setNamePrefix($name_prefix);
|
|
|
|
}
|
2012-08-07 18:29:34 +02:00
|
|
|
if ($context !== null) {
|
|
|
|
$query->setContext($context);
|
|
|
|
}
|
2011-12-21 18:39:33 +01:00
|
|
|
if ($language !== null) {
|
|
|
|
$query->setLanguage($language);
|
|
|
|
}
|
|
|
|
if ($type !== null) {
|
|
|
|
$query->setType($type);
|
|
|
|
}
|
|
|
|
|
|
|
|
$query->needPaths(true);
|
|
|
|
$query->needArcanistProjects(true);
|
|
|
|
$query->needRepositories(true);
|
|
|
|
|
|
|
|
$results = $query->execute();
|
|
|
|
|
2012-07-10 02:51:42 +02:00
|
|
|
|
2011-12-21 18:39:33 +01:00
|
|
|
$response = array();
|
|
|
|
foreach ($results as $result) {
|
2012-07-10 02:51:42 +02:00
|
|
|
$uri = $result->getURI();
|
|
|
|
if ($uri) {
|
|
|
|
$uri = PhabricatorEnv::getProductionURI($uri);
|
|
|
|
}
|
|
|
|
|
2011-12-21 18:39:33 +01:00
|
|
|
$response[] = array(
|
|
|
|
'name' => $result->getSymbolName(),
|
2012-08-07 18:29:34 +02:00
|
|
|
'context' => $result->getSymbolContext(),
|
2011-12-21 18:39:33 +01:00
|
|
|
'type' => $result->getSymbolType(),
|
|
|
|
'language' => $result->getSymbolLanguage(),
|
|
|
|
'path' => $result->getPath(),
|
|
|
|
'line' => $result->getLineNumber(),
|
2012-07-10 02:51:42 +02:00
|
|
|
'uri' => $uri,
|
2011-12-21 18:39:33 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $response;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|