Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/diffusion/conduit/DiffusionFindSymbolsConduitAPIMethod.php
12242 views
1
<?php
2
3
final class DiffusionFindSymbolsConduitAPIMethod
4
extends DiffusionConduitAPIMethod {
5
6
public function getAPIMethodName() {
7
return 'diffusion.findsymbols';
8
}
9
10
public function getMethodDescription() {
11
return pht('Retrieve Diffusion symbol information.');
12
}
13
14
protected function defineParamTypes() {
15
return array(
16
'name' => 'optional string',
17
'namePrefix' => 'optional string',
18
'context' => 'optional string',
19
'language' => 'optional string',
20
'type' => 'optional string',
21
'repositoryPHID' => 'optional string',
22
);
23
}
24
25
protected function defineReturnType() {
26
return 'nonempty list<dict>';
27
}
28
29
protected function execute(ConduitAPIRequest $request) {
30
$name = $request->getValue('name');
31
$name_prefix = $request->getValue('namePrefix');
32
$context = $request->getValue('context');
33
$language = $request->getValue('language');
34
$type = $request->getValue('type');
35
$repository = $request->getValue('repositoryPHID');
36
37
$query = id(new DiffusionSymbolQuery())
38
->setViewer($request->getUser());
39
if ($name !== null) {
40
$query->setName($name);
41
}
42
if ($name_prefix !== null) {
43
$query->setNamePrefix($name_prefix);
44
}
45
if ($context !== null) {
46
$query->setContext($context);
47
}
48
if ($language !== null) {
49
$query->setLanguage($language);
50
}
51
if ($type !== null) {
52
$query->setType($type);
53
}
54
if ($repository !== null) {
55
$query->withRepositoryPHIDs(array($repository));
56
}
57
58
$query->needPaths(true);
59
$query->needRepositories(true);
60
61
$results = $query->execute();
62
63
64
$response = array();
65
foreach ($results as $result) {
66
$uri = $result->getURI();
67
if ($uri) {
68
$uri = PhabricatorEnv::getProductionURI($uri);
69
}
70
71
$response[] = array(
72
'name' => $result->getSymbolName(),
73
'context' => $result->getSymbolContext(),
74
'type' => $result->getSymbolType(),
75
'language' => $result->getSymbolLanguage(),
76
'path' => $result->getPath(),
77
'line' => $result->getLineNumber(),
78
'uri' => $uri,
79
'repositoryPHID' => $result->getRepository()->getPHID(),
80
);
81
}
82
83
return $response;
84
}
85
86
}
87
88