@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
3abstract class PhabricatorApplicationConfigurationPanel
4 extends Phobject {
5
6 private $viewer;
7 private $application;
8
9 public function setViewer(PhabricatorUser $viewer) {
10 $this->viewer = $viewer;
11 return $this;
12 }
13
14 public function getViewer() {
15 return $this->viewer;
16 }
17
18 public function setApplication(PhabricatorApplication $application) {
19 $this->application = $application;
20 return $this;
21 }
22
23 public function getApplication() {
24 return $this->application;
25 }
26
27 /**
28 * Get the URI for this application configuration panel.
29 *
30 * @param string $path (optional) Path to append.
31 * @return string Relative URI for the panel.
32 */
33 public function getPanelURI($path = '') {
34 $app_key = get_class($this->getApplication());
35 $panel_key = $this->getPanelKey();
36 $base = "/applications/panel/{$app_key}/{$panel_key}/";
37 return $base.ltrim($path, '/');
38 }
39
40 /**
41 * Return a short, unique string key which identifies this panel.
42 *
43 * This key is used in URIs. Good values might be "email" or "files".
44 */
45 abstract public function getPanelKey();
46
47 abstract public function shouldShowForApplication(
48 PhabricatorApplication $application);
49
50 abstract public function buildConfigurationPagePanel();
51 abstract public function handlePanelRequest(
52 AphrontRequest $request,
53 PhabricatorController $controller);
54
55 public static function loadAllPanels() {
56 return id(new PhutilClassMapQuery())
57 ->setAncestorClass(self::class)
58 ->setUniqueMethod('getPanelKey')
59 ->execute();
60 }
61
62 public static function loadAllPanelsForApplication(
63 PhabricatorApplication $application) {
64 $panels = self::loadAllPanels();
65
66 $application_panels = array();
67 foreach ($panels as $key => $panel) {
68 if (!$panel->shouldShowForApplication($application)) {
69 continue;
70 }
71 $application_panels[$key] = $panel;
72 }
73
74 return $application_panels;
75 }
76
77}