Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / diffusion / controller / DiffusionPathTreeController.php
blob231c7b6208f7b35d47350c18f9688b635dad105f
1 <?php
3 final class DiffusionPathTreeController extends DiffusionController {
5 public function handleRequest(AphrontRequest $request) {
6 $response = $this->loadDiffusionContext();
7 if ($response) {
8 return $response;
11 $drequest = $this->getDiffusionRequest();
12 $repository = $drequest->getRepository();
14 if (!$repository->canUsePathTree()) {
15 return new Aphront404Response();
18 $paths = $this->callConduitWithDiffusionRequest(
19 'diffusion.querypaths',
20 array(
21 'path' => $drequest->getPath(),
22 'commit' => $drequest->getCommit(),
23 ));
25 $tree = array();
26 foreach ($paths as $path) {
27 $parts = preg_split('((?<=/))', $path);
28 $cursor = &$tree;
29 foreach ($parts as $part) {
30 if (!is_array($cursor)) {
31 $cursor = array();
33 if (!isset($cursor[$part])) {
34 $cursor[$part] = 1;
36 $cursor = &$cursor[$part];
40 return id(new AphrontAjaxResponse())->setContent(array('tree' => $tree));