@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class DiffusionPathTreeController extends DiffusionController {
4
5 public function handleRequest(AphrontRequest $request) {
6 $response = $this->loadDiffusionContext();
7 if ($response) {
8 return $response;
9 }
10
11 $drequest = $this->getDiffusionRequest();
12 $repository = $drequest->getRepository();
13
14 if (!$repository->canUsePathTree()) {
15 return new Aphront404Response();
16 }
17
18 $paths = $this->callConduitWithDiffusionRequest(
19 'diffusion.querypaths',
20 array(
21 'path' => $drequest->getPath(),
22 'commit' => $drequest->getCommit(),
23 ));
24
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();
32 }
33 if (!isset($cursor[$part])) {
34 $cursor[$part] = 1;
35 }
36 $cursor = &$cursor[$part];
37 }
38 }
39
40 return id(new AphrontAjaxResponse())->setContent(array('tree' => $tree));
41 }
42}