Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / config / storage / PhabricatorConfigEntry.php
blob3462c4e7ba50ab665e684214013e7a3090b79a04
1 <?php
3 final class PhabricatorConfigEntry
4 extends PhabricatorConfigEntryDAO
5 implements
6 PhabricatorApplicationTransactionInterface,
7 PhabricatorPolicyInterface {
9 protected $namespace;
10 protected $configKey;
11 protected $value;
12 protected $isDeleted;
14 protected function getConfiguration() {
15 return array(
16 self::CONFIG_AUX_PHID => true,
17 self::CONFIG_SERIALIZATION => array(
18 'value' => self::SERIALIZATION_JSON,
20 self::CONFIG_COLUMN_SCHEMA => array(
21 'namespace' => 'text64',
22 'configKey' => 'text64',
23 'isDeleted' => 'bool',
25 self::CONFIG_KEY_SCHEMA => array(
26 'key_name' => array(
27 'columns' => array('namespace', 'configKey'),
28 'unique' => true,
31 ) + parent::getConfiguration();
34 public function generatePHID() {
35 return PhabricatorPHID::generateNewPHID(
36 PhabricatorConfigConfigPHIDType::TYPECONST);
39 public static function loadConfigEntry($key) {
40 $config_entry = id(new PhabricatorConfigEntry())
41 ->loadOneWhere(
42 'configKey = %s AND namespace = %s',
43 $key,
44 'default');
46 if (!$config_entry) {
47 $config_entry = id(new PhabricatorConfigEntry())
48 ->setConfigKey($key)
49 ->setNamespace('default')
50 ->setIsDeleted(0);
53 return $config_entry;
57 /* -( PhabricatorApplicationTransactionInterface )------------------------- */
60 public function getApplicationTransactionEditor() {
61 return new PhabricatorConfigEditor();
64 public function getApplicationTransactionTemplate() {
65 return new PhabricatorConfigTransaction();
69 /* -( PhabricatorPolicyInterface )----------------------------------------- */
72 public function getCapabilities() {
73 return array(
74 PhabricatorPolicyCapability::CAN_VIEW,
75 PhabricatorPolicyCapability::CAN_EDIT,
79 public function getPolicy($capability) {
80 return PhabricatorPolicies::POLICY_ADMIN;
83 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
84 return false;