Correct a parameter order swap in "diffusion.historyquery" for Mercurial
[phabricator.git] / src / applications / diffusion / controller / DiffusionCommitBranchesController.php
blob633c3b9174aa745ffdb530d156e8a16f1d27dafd
1 <?php
3 final class DiffusionCommitBranchesController extends DiffusionController {
5 public function shouldAllowPublic() {
6 return true;
9 public function handleRequest(AphrontRequest $request) {
10 $response = $this->loadDiffusionContext();
11 if ($response) {
12 return $response;
15 $drequest = $this->getDiffusionRequest();
16 $repository = $drequest->getRepository();
18 $branch_limit = 10;
19 $branches = DiffusionRepositoryRef::loadAllFromDictionaries(
20 $this->callConduitWithDiffusionRequest(
21 'diffusion.branchquery',
22 array(
23 'contains' => $drequest->getCommit(),
24 'limit' => $branch_limit + 1,
25 'branch' => null,
26 )));
28 $has_more_branches = (count($branches) > $branch_limit);
29 $branches = array_slice($branches, 0, $branch_limit);
31 $branch_links = array();
32 foreach ($branches as $branch) {
33 $branch_links[] = phutil_tag(
34 'a',
35 array(
36 'href' => $drequest->generateURI(
37 array(
38 'action' => 'browse',
39 'branch' => $branch->getShortName(),
40 )),
42 $branch->getShortName());
45 if ($has_more_branches) {
46 $branch_links[] = phutil_tag(
47 'a',
48 array(
49 'href' => $drequest->generateURI(
50 array(
51 'action' => 'branches',
52 )),
54 pht("More Branches\xE2\x80\xA6"));
57 return id(new AphrontAjaxResponse())
58 ->setContent($branch_links ? implode(', ', $branch_links) : pht('None'));