Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/diffusion/controller/DiffusionPathCompleteController.php
12242 views
1
<?php
2
3
final class DiffusionPathCompleteController extends DiffusionController {
4
5
protected function getRepositoryIdentifierFromRequest(
6
AphrontRequest $request) {
7
return $request->getStr('repositoryPHID');
8
}
9
10
public function handleRequest(AphrontRequest $request) {
11
$response = $this->loadDiffusionContext();
12
if ($response) {
13
return $response;
14
}
15
16
$viewer = $this->getViewer();
17
$drequest = $this->getDiffusionRequest();
18
19
$query_path = $request->getStr('q');
20
if (preg_match('@/$@', $query_path)) {
21
$query_dir = $query_path;
22
} else {
23
$query_dir = dirname($query_path).'/';
24
}
25
$query_dir = ltrim($query_dir, '/');
26
27
$browse_results = DiffusionBrowseResultSet::newFromConduit(
28
$this->callConduitWithDiffusionRequest(
29
'diffusion.browsequery',
30
array(
31
'path' => $query_dir,
32
'commit' => $drequest->getCommit(),
33
)));
34
$paths = $browse_results->getPaths();
35
36
$output = array();
37
foreach ($paths as $path) {
38
$full_path = $query_dir.$path->getPath();
39
if ($path->getFileType() == DifferentialChangeType::FILE_DIRECTORY) {
40
$full_path .= '/';
41
}
42
$output[] = array('/'.$full_path, null, substr(md5($full_path), 0, 7));
43
}
44
45
return id(new AphrontAjaxResponse())->setContent($output);
46
}
47
}
48
49