@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 PhabricatorApplicationPanelController
4 extends PhabricatorApplicationsController {
5
6 private $application;
7
8 public function handleRequest(AphrontRequest $request) {
9 $viewer = $this->getViewer();
10
11 $application = $request->getURIData('application');
12 $panel_key = $request->getURIData('panel');
13
14 $selected = id(new PhabricatorApplicationQuery())
15 ->setViewer($viewer)
16 ->withClasses(array($application))
17 ->requireCapabilities(
18 array(
19 PhabricatorPolicyCapability::CAN_VIEW,
20 PhabricatorPolicyCapability::CAN_EDIT,
21 ))
22 ->executeOne();
23 if (!$selected) {
24 return new Aphront404Response();
25 }
26
27 $panels =
28 PhabricatorApplicationConfigurationPanel::loadAllPanelsForApplication(
29 $selected);
30 if (empty($panels[$panel_key])) {
31 return new Aphront404Response();
32 }
33
34 $panel = $panels[$panel_key];
35
36 if (!$panel->shouldShowForApplication($selected)) {
37 return new Aphront404Response();
38 }
39
40 $panel->setViewer($viewer);
41 $panel->setApplication($selected);
42
43 $this->application = $selected;
44
45 return $panel->handlePanelRequest($request, $this);
46 }
47
48 public function buildPanelCrumbs(
49 PhabricatorApplicationConfigurationPanel $panel) {
50 $application = $this->application;
51
52 $crumbs = $this->buildApplicationCrumbs();
53
54 $view_uri = '/applications/view/'.get_class($application).'/';
55 $crumbs->addTextCrumb($application->getName(), $view_uri);
56
57 return $crumbs;
58 }
59
60 public function buildPanelPage(
61 PhabricatorApplicationConfigurationPanel $panel,
62 $title,
63 $crumbs,
64 $content) {
65
66 return $this->newPage()
67 ->setTitle($title)
68 ->setCrumbs($crumbs)
69 ->appendChild($content);
70 }
71
72}