diff --git a/src/applications/config/controller/PhabricatorConfigEditController.php b/src/applications/config/controller/PhabricatorConfigEditController.php index c3a277c087..78b9f96e0c 100644 --- a/src/applications/config/controller/PhabricatorConfigEditController.php +++ b/src/applications/config/controller/PhabricatorConfigEditController.php @@ -253,6 +253,7 @@ final class PhabricatorConfigEditController } break; case 'string': + case 'enum': $set_value = (string)$value; break; case 'list': @@ -328,6 +329,7 @@ final class PhabricatorConfigEditController switch ($type) { case 'int': case 'string': + case 'enum': return $value; case 'bool': return $value ? 'true' : 'false'; @@ -360,6 +362,15 @@ final class PhabricatorConfigEditController 'false' => idx($option->getBoolOptions(), 1), )); break; + case 'enum': + $options = array_mergev( + array( + array('' => pht('(Use Default)')), + $option->getEnumOptions(), + )); + $control = id(new AphrontFormSelectControl()) + ->setOptions($options); + break; case 'class': $symbols = id(new PhutilSymbolLoader()) ->setType('class') diff --git a/src/applications/config/management/PhabricatorConfigManagementSetWorkflow.php b/src/applications/config/management/PhabricatorConfigManagementSetWorkflow.php index df678b79a1..d3becd3296 100644 --- a/src/applications/config/management/PhabricatorConfigManagementSetWorkflow.php +++ b/src/applications/config/management/PhabricatorConfigManagementSetWorkflow.php @@ -53,6 +53,7 @@ final class PhabricatorConfigManagementSetWorkflow switch ($type) { case 'string': case 'class': + case 'enum': $value = (string)$value; break; case 'int': diff --git a/src/applications/config/option/PhabricatorConfigOption.php b/src/applications/config/option/PhabricatorConfigOption.php index df3a780ab4..5d0b5a286f 100644 --- a/src/applications/config/option/PhabricatorConfigOption.php +++ b/src/applications/config/option/PhabricatorConfigOption.php @@ -10,6 +10,7 @@ final class PhabricatorConfigOption private $description; private $type; private $boolOptions; + private $enumOptions; private $group; private $examples; private $locked; @@ -115,6 +116,20 @@ final class PhabricatorConfigOption ); } + public function setEnumOptions(array $options) { + $this->enumOptions = $options; + return $this; + } + + public function getEnumOptions() { + if ($this->enumOptions) { + return $this->enumOptions; + } + + throw new Exception( + 'Call setEnumOptions() before trying to access them!'); + } + public function setKey($key) { $this->key = $key; return $this; diff --git a/src/applications/config/option/PhabricatorMetaMTAConfigOptions.php b/src/applications/config/option/PhabricatorMetaMTAConfigOptions.php index b3c188f335..19437ffffe 100644 --- a/src/applications/config/option/PhabricatorMetaMTAConfigOptions.php +++ b/src/applications/config/option/PhabricatorMetaMTAConfigOptions.php @@ -317,10 +317,20 @@ EODOC ->setSummary( pht('Allow Phabricator to use a single mailbox for all replies.')) ->setDescription($single_description), - // TODO: 'enum' - $this->newOption('metamta.user-address-format', 'string', 'full') + $this->newOption('metamta.user-address-format', 'enum', 'full') + ->setEnumOptions( + array( + 'short' => 'short', + 'real' => 'real', + 'full' => 'full', + )) ->setSummary(pht('Control how Phabricator renders user names in mail.')) - ->setDescription($address_description), + ->setDescription($address_description) + ->addExample('gwashington ', 'short') + ->addExample('George Washington ', 'real') + ->addExample( + 'gwashington (George Washington) ', + 'full'), ); }