@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 PhabricatorConfigEntry
4 extends PhabricatorConfigEntryDAO
5 implements
6 PhabricatorApplicationTransactionInterface,
7 PhabricatorPolicyInterface {
8
9 protected $namespace;
10 protected $configKey;
11 protected $value;
12 protected $isDeleted;
13
14 protected function getConfiguration() {
15 return array(
16 self::CONFIG_AUX_PHID => true,
17 self::CONFIG_SERIALIZATION => array(
18 'value' => self::SERIALIZATION_JSON,
19 ),
20 self::CONFIG_COLUMN_SCHEMA => array(
21 'namespace' => 'text64',
22 'configKey' => 'text64',
23 'isDeleted' => 'bool',
24 ),
25 self::CONFIG_KEY_SCHEMA => array(
26 'key_name' => array(
27 'columns' => array('namespace', 'configKey'),
28 'unique' => true,
29 ),
30 ),
31 ) + parent::getConfiguration();
32 }
33
34 public function generatePHID() {
35 return PhabricatorPHID::generateNewPHID(
36 PhabricatorConfigConfigPHIDType::TYPECONST);
37 }
38
39 public static function loadConfigEntry($key) {
40 $config_entry = id(new PhabricatorConfigEntry())
41 ->loadOneWhere(
42 'configKey = %s AND namespace = %s',
43 $key,
44 'default');
45
46 if (!$config_entry) {
47 $config_entry = id(new PhabricatorConfigEntry())
48 ->setConfigKey($key)
49 ->setNamespace('default')
50 ->setIsDeleted(0);
51 }
52
53 return $config_entry;
54 }
55
56
57/* -( PhabricatorApplicationTransactionInterface )------------------------- */
58
59
60 public function getApplicationTransactionEditor() {
61 return new PhabricatorConfigEditor();
62 }
63
64 public function getApplicationTransactionTemplate() {
65 return new PhabricatorConfigTransaction();
66 }
67
68
69/* -( PhabricatorPolicyInterface )----------------------------------------- */
70
71
72 public function getCapabilities() {
73 return array(
74 PhabricatorPolicyCapability::CAN_VIEW,
75 PhabricatorPolicyCapability::CAN_EDIT,
76 );
77 }
78
79 public function getPolicy($capability) {
80 return PhabricatorPolicies::POLICY_ADMIN;
81 }
82
83 public function hasAutomaticCapability($capability, PhabricatorUser $viewer) {
84 return false;
85 }
86
87}