Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / meta / panel / PhabricatorApplicationConfigurationPanel.php
blob358a6f753b061d5f426d442b67cfbccfd5d1d4c7
1 <?php
3 abstract class PhabricatorApplicationConfigurationPanel
4 extends Phobject {
6 private $viewer;
7 private $application;
9 public function setViewer(PhabricatorUser $viewer) {
10 $this->viewer = $viewer;
11 return $this;
14 public function getViewer() {
15 return $this->viewer;
18 public function setApplication(PhabricatorApplication $application) {
19 $this->application = $application;
20 return $this;
23 public function getApplication() {
24 return $this->application;
27 public function getPanelURI($path = null) {
28 $app_key = get_class($this->getApplication());
29 $panel_key = $this->getPanelKey();
30 $base = "/applications/panel/{$app_key}/{$panel_key}/";
31 return $base.ltrim($path, '/');
34 /**
35 * Return a short, unique string key which identifies this panel.
37 * This key is used in URIs. Good values might be "email" or "files".
39 abstract public function getPanelKey();
41 abstract public function shouldShowForApplication(
42 PhabricatorApplication $application);
44 abstract public function buildConfigurationPagePanel();
45 abstract public function handlePanelRequest(
46 AphrontRequest $request,
47 PhabricatorController $controller);
49 public static function loadAllPanels() {
50 return id(new PhutilClassMapQuery())
51 ->setAncestorClass(__CLASS__)
52 ->setUniqueMethod('getPanelKey')
53 ->execute();
56 public static function loadAllPanelsForApplication(
57 PhabricatorApplication $application) {
58 $panels = self::loadAllPanels();
60 $application_panels = array();
61 foreach ($panels as $key => $panel) {
62 if (!$panel->shouldShowForApplication($application)) {
63 continue;
65 $application_panels[$key] = $panel;
68 return $application_panels;