@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
fork

Configure Feed

Select the types of activity you want to include in your feed.

at recaptime-dev/main 254 lines 5.2 kB view raw
1<?php 2 3final class PhabricatorConfigOption 4 extends Phobject { 5 6 private $key; 7 private $default; 8 private $summary; 9 private $description; 10 private $type; 11 private $boolOptions; 12 private $enumOptions; 13 private $group; 14 private $examples; 15 private $locked; 16 private $lockedMessage; 17 private $hidden; 18 private $baseClass; 19 private $customData; 20 private $customObject; 21 22 public function setBaseClass($base_class) { 23 $this->baseClass = $base_class; 24 return $this; 25 } 26 27 public function getBaseClass() { 28 return $this->baseClass; 29 } 30 31 public function setHidden($hidden) { 32 $this->hidden = $hidden; 33 return $this; 34 } 35 36 public function getHidden() { 37 if ($this->hidden) { 38 return true; 39 } 40 41 return idx( 42 PhabricatorEnv::getEnvConfig('config.hide'), 43 $this->getKey(), 44 false); 45 } 46 47 public function setLocked($locked) { 48 $this->locked = $locked; 49 return $this; 50 } 51 52 public function getLocked() { 53 if ($this->locked) { 54 return true; 55 } 56 57 if ($this->getHidden()) { 58 return true; 59 } 60 61 return idx( 62 PhabricatorEnv::getEnvConfig('config.lock'), 63 $this->getKey(), 64 false); 65 } 66 67 public function setLockedMessage($message) { 68 $this->lockedMessage = $message; 69 return $this; 70 } 71 72 public function getLockedMessage() { 73 if ($this->lockedMessage !== null) { 74 return $this->lockedMessage; 75 } 76 return pht( 77 'This configuration is locked and can not be edited from the web '. 78 'interface. Use %s in %s to edit it.', 79 phutil_tag('tt', array(), './bin/config'), 80 phutil_tag('tt', array(), PlatformSymbols::getPlatformServerPath())); 81 } 82 83 public function addExample($value, $description) { 84 $this->examples[] = array($value, $description); 85 return $this; 86 } 87 88 /** 89 * @return array Pairs of a config value and its description 90 */ 91 public function getExamples() { 92 return $this->examples; 93 } 94 95 public function setGroup(PhabricatorApplicationConfigOptions $group) { 96 $this->group = $group; 97 return $this; 98 } 99 100 public function getGroup() { 101 return $this->group; 102 } 103 104 public function setBoolOptions(array $options) { 105 $this->boolOptions = $options; 106 return $this; 107 } 108 109 /** 110 * @return array Array of boolean options, defaults to True and False 111 */ 112 public function getBoolOptions() { 113 if ($this->boolOptions) { 114 return $this->boolOptions; 115 } 116 return array( 117 pht('True'), 118 pht('False'), 119 ); 120 } 121 122 public function setEnumOptions(array $options) { 123 $this->enumOptions = $options; 124 return $this; 125 } 126 127 public function getEnumOptions() { 128 if ($this->enumOptions) { 129 return $this->enumOptions; 130 } 131 132 throw new PhutilInvalidStateException('setEnumOptions'); 133 } 134 135 /** 136 * Set the config key. 137 * 138 * @param string $key 139 * @return $this 140 */ 141 public function setKey($key) { 142 $this->key = $key; 143 return $this; 144 } 145 146 /** 147 * Get the config key. 148 * 149 * @return string 150 */ 151 public function getKey() { 152 return $this->key; 153 } 154 155 public function setDefault($default) { 156 $this->default = $default; 157 return $this; 158 } 159 160 public function getDefault() { 161 return $this->default; 162 } 163 164 public function setSummary($summary) { 165 $this->summary = $summary; 166 return $this; 167 } 168 169 public function getSummary() { 170 if (empty($this->summary)) { 171 return $this->getDescription(); 172 } 173 return $this->summary; 174 } 175 176 /** 177 * Set the human Description of this Config 178 * 179 * @param string|null $description Description as raw Remarkup 180 * @return self 181 */ 182 public function setDescription($description) { 183 $this->description = $description; 184 return $this; 185 } 186 187 /** 188 * Get the human Description of this Config 189 * 190 * @return string|null Description as raw Remarkup 191 */ 192 public function getDescription() { 193 return $this->description; 194 } 195 196 /** 197 * Set the type key. 198 * 199 * @param string $type Type key. 200 * @return $this 201 */ 202 public function setType($type) { 203 $this->type = $type; 204 return $this; 205 } 206 207 /** 208 * Get the type key. 209 * 210 * @return string|null 211 */ 212 public function getType() { 213 return $this->type; 214 } 215 216 public function newOptionType() { 217 $type_key = $this->getType(); 218 $type_map = PhabricatorConfigType::getAllTypes(); 219 return idx($type_map, $type_key); 220 } 221 222 public function isCustomType() { 223 return !strncmp($this->getType(), 'custom:', 7); 224 } 225 226 public function getCustomObject() { 227 if (!$this->customObject) { 228 if (!$this->isCustomType()) { 229 throw new Exception(pht('This option does not have a custom type!')); 230 } 231 $this->customObject = newv(substr($this->getType(), 7), array()); 232 } 233 return $this->customObject; 234 } 235 236 public function getCustomData() { 237 return $this->customData; 238 } 239 240 public function setCustomData($data) { 241 $this->customData = $data; 242 return $this; 243 } 244 245 public function newDescriptionRemarkupView(PhabricatorUser $viewer) { 246 $description = $this->getDescription(); 247 if (!phutil_nonempty_string($description)) { 248 return null; 249 } 250 251 return new PHUIRemarkupView($viewer, $description); 252 } 253 254}