Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / settings / panel / PhabricatorEditEngineSettingsPanel.php
bloba4c9c3b78975742ae445940b7735ebf3c6d285f3
1 <?php
3 abstract class PhabricatorEditEngineSettingsPanel
4 extends PhabricatorSettingsPanel {
6 final public function processRequest(AphrontRequest $request) {
7 $viewer = $this->getViewer();
8 $user = $this->getUser();
10 if ($user && ($user->getPHID() === $viewer->getPHID())) {
11 $is_self = true;
12 } else {
13 $is_self = false;
16 if ($user && $user->getPHID()) {
17 $profile_uri = '/people/manage/'.$user->getID().'/';
18 } else {
19 $profile_uri = null;
22 $engine = id(new PhabricatorSettingsEditEngine())
23 ->setController($this->getController())
24 ->setNavigation($this->getNavigation())
25 ->setSettingsPanel($this)
26 ->setIsSelfEdit($is_self)
27 ->setProfileURI($profile_uri);
29 $preferences = $this->getPreferences();
31 $engine->setTargetObject($preferences);
33 return $engine->buildResponse();
36 final public function isEnabled() {
37 // Only enable the panel if it has any fields.
38 $field_keys = $this->getPanelSettingsKeys();
39 return (bool)$field_keys;
42 final public function newEditEnginePage() {
43 $field_keys = $this->getPanelSettingsKeys();
44 if (!$field_keys) {
45 return null;
48 $key = $this->getPanelKey();
49 $label = $this->getPanelName();
50 $panel_uri = $this->getPanelURI();
52 return id(new PhabricatorEditPage())
53 ->setKey($key)
54 ->setLabel($label)
55 ->setViewURI($panel_uri)
56 ->setFieldKeys($field_keys);
59 final public function getPanelSettingsKeys() {
60 $viewer = $this->getViewer();
61 $settings = PhabricatorSetting::getAllEnabledSettings($viewer);
63 $this_key = $this->getPanelKey();
65 $panel_settings = array();
66 foreach ($settings as $setting) {
67 if ($setting->getSettingPanelKey() == $this_key) {
68 $panel_settings[] = $setting;
72 return mpull($panel_settings, 'getSettingKey');
75 public function newSettingsPanelEditFormHeadContent(
76 PhabricatorEditEnginePageState $state) {
77 return null;
80 public function newSettingsPanelEditFormTailContent(
81 PhabricatorEditEnginePageState $state) {
82 return null;