Path: blob/master/src/applications/config/option/PhabricatorConfigOption.php
12256 views
<?php12final class PhabricatorConfigOption3extends Phobject {45private $key;6private $default;7private $summary;8private $description;9private $type;10private $boolOptions;11private $enumOptions;12private $group;13private $examples;14private $locked;15private $lockedMessage;16private $hidden;17private $baseClass;18private $customData;19private $customObject;2021public function setBaseClass($base_class) {22$this->baseClass = $base_class;23return $this;24}2526public function getBaseClass() {27return $this->baseClass;28}2930public function setHidden($hidden) {31$this->hidden = $hidden;32return $this;33}3435public function getHidden() {36if ($this->hidden) {37return true;38}3940return idx(41PhabricatorEnv::getEnvConfig('config.hide'),42$this->getKey(),43false);44}4546public function setLocked($locked) {47$this->locked = $locked;48return $this;49}5051public function getLocked() {52if ($this->locked) {53return true;54}5556if ($this->getHidden()) {57return true;58}5960return idx(61PhabricatorEnv::getEnvConfig('config.lock'),62$this->getKey(),63false);64}6566public function setLockedMessage($message) {67$this->lockedMessage = $message;68return $this;69}7071public function getLockedMessage() {72if ($this->lockedMessage !== null) {73return $this->lockedMessage;74}75return pht(76'This configuration is locked and can not be edited from the web '.77'interface. Use %s in %s to edit it.',78phutil_tag('tt', array(), './bin/config'),79phutil_tag('tt', array(), 'phabricator/'));80}8182public function addExample($value, $description) {83$this->examples[] = array($value, $description);84return $this;85}8687public function getExamples() {88return $this->examples;89}9091public function setGroup(PhabricatorApplicationConfigOptions $group) {92$this->group = $group;93return $this;94}9596public function getGroup() {97return $this->group;98}99100public function setBoolOptions(array $options) {101$this->boolOptions = $options;102return $this;103}104105public function getBoolOptions() {106if ($this->boolOptions) {107return $this->boolOptions;108}109return array(110pht('True'),111pht('False'),112);113}114115public function setEnumOptions(array $options) {116$this->enumOptions = $options;117return $this;118}119120public function getEnumOptions() {121if ($this->enumOptions) {122return $this->enumOptions;123}124125throw new PhutilInvalidStateException('setEnumOptions');126}127128public function setKey($key) {129$this->key = $key;130return $this;131}132133public function getKey() {134return $this->key;135}136137public function setDefault($default) {138$this->default = $default;139return $this;140}141142public function getDefault() {143return $this->default;144}145146public function setSummary($summary) {147$this->summary = $summary;148return $this;149}150151public function getSummary() {152if (empty($this->summary)) {153return $this->getDescription();154}155return $this->summary;156}157158public function setDescription($description) {159$this->description = $description;160return $this;161}162163public function getDescription() {164return $this->description;165}166167public function setType($type) {168$this->type = $type;169return $this;170}171172public function getType() {173return $this->type;174}175176public function newOptionType() {177$type_key = $this->getType();178$type_map = PhabricatorConfigType::getAllTypes();179return idx($type_map, $type_key);180}181182public function isCustomType() {183return !strncmp($this->getType(), 'custom:', 7);184}185186public function getCustomObject() {187if (!$this->customObject) {188if (!$this->isCustomType()) {189throw new Exception(pht('This option does not have a custom type!'));190}191$this->customObject = newv(substr($this->getType(), 7), array());192}193return $this->customObject;194}195196public function getCustomData() {197return $this->customData;198}199200public function setCustomData($data) {201$this->customData = $data;202return $this;203}204205public function newDescriptionRemarkupView(PhabricatorUser $viewer) {206$description = $this->getDescription();207if (!strlen($description)) {208return null;209}210211return new PHUIRemarkupView($viewer, $description);212}213214}215216217