Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / diffusion / controller / DiffusionPathValidateController.php
blob62e9e04796ed7ed09fd3b50f705b60afb076dff6
1 <?php
3 final class DiffusionPathValidateController 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();
18 $repository = $drequest->getRepository();
20 $path = $request->getStr('path');
21 $path = ltrim($path, '/');
23 $browse_results = DiffusionBrowseResultSet::newFromConduit(
24 $this->callConduitWithDiffusionRequest(
25 'diffusion.browsequery',
26 array(
27 'path' => $path,
28 'commit' => $drequest->getCommit(),
29 'needValidityOnly' => true,
30 )));
31 $valid = $browse_results->isValidResults();
33 if (!$valid) {
34 switch ($browse_results->getReasonForEmptyResultSet()) {
35 case DiffusionBrowseResultSet::REASON_IS_FILE:
36 $valid = true;
37 break;
38 case DiffusionBrowseResultSet::REASON_IS_EMPTY:
39 $valid = true;
40 break;
44 $output = array(
45 'valid' => (bool)$valid,
48 return id(new AphrontAjaxResponse())->setContent($output);