Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / diffusion / controller / DiffusionPathCompleteController.php
blob999a04dbf854c7474a5abb2df1d70a8848bd81e7
1 <?php
3 final class DiffusionPathCompleteController extends DiffusionController {
5 protected function getRepositoryIdentifierFromRequest(
6 AphrontRequest $request) {
7 return $request->getStr('repositoryPHID');
10 public function handleRequest(AphrontRequest $request) {
11 $response = $this->loadDiffusionContext();
12 if ($response) {
13 return $response;
16 $viewer = $this->getViewer();
17 $drequest = $this->getDiffusionRequest();
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).'/';
25 $query_dir = ltrim($query_dir, '/');
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();
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 .= '/';
42 $output[] = array('/'.$full_path, null, substr(md5($full_path), 0, 7));
45 return id(new AphrontAjaxResponse())->setContent($output);