1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-02-08 12:58:31 +01:00

Default to "True" and "False" for bool options.

Summary:
Rather than throwing if we don't `setOptions()`, let's just default to `true`
and `false`.

Test Plan:
Removed a `setOptions()` call temporarily and saw options default to
`true` / `false`.

Reviewers: epriestley, btrahan, chad

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T2255

Differential Revision: https://secure.phabricator.com/D4368
This commit is contained in:
Ricky Elrod 2013-01-09 08:14:26 -08:00 committed by epriestley
parent f12dbe36d6
commit 71b5d8f584
15 changed files with 48 additions and 42 deletions

View file

@ -350,8 +350,8 @@ final class PhabricatorConfigEditController
->setOptions( ->setOptions(
array( array(
'' => pht('(Use Default)'), '' => pht('(Use Default)'),
'true' => idx($option->getOptions(), 0), 'true' => idx($option->getBoolOptions(), 0),
'false' => idx($option->getOptions(), 1), 'false' => idx($option->getBoolOptions(), 1),
)); ));
break; break;
case 'class': case 'class':

View file

@ -15,7 +15,7 @@ final class PhabricatorAuthenticationConfigOptions
return array( return array(
$this->newOption( $this->newOption(
'auth.password-auth-enabled', 'bool', true) 'auth.password-auth-enabled', 'bool', true)
->setOptions( ->setBoolOptions(
array( array(
pht("Allow password authentication"), pht("Allow password authentication"),
pht("Don't allow password authentication") pht("Don't allow password authentication")
@ -43,7 +43,7 @@ final class PhabricatorAuthenticationConfigOptions
"Maximum number of simultaneous Conduit sessions each user is ". "Maximum number of simultaneous Conduit sessions each user is ".
"permitted to have.")), "permitted to have.")),
$this->newOption('auth.sshkeys.enabled', 'bool', false) $this->newOption('auth.sshkeys.enabled', 'bool', false)
->setOptions( ->setBoolOptions(
array( array(
pht("Enable SSH key storage"), pht("Enable SSH key storage"),
pht("Disable SSH key storage"))) pht("Disable SSH key storage")))
@ -58,7 +58,7 @@ final class PhabricatorAuthenticationConfigOptions
"authentication; in most situations you can leave this ". "authentication; in most situations you can leave this ".
"disabled.")), "disabled.")),
$this->newOption('auth.require-email-verification', 'bool', false) $this->newOption('auth.require-email-verification', 'bool', false)
->setOptions( ->setBoolOptions(
array( array(
pht("Require email verification"), pht("Require email verification"),
pht("Don't require email verification") pht("Don't require email verification")
@ -95,7 +95,7 @@ final class PhabricatorAuthenticationConfigOptions
"appear on the login screen. Normally, you'd use this to provide ". "appear on the login screen. Normally, you'd use this to provide ".
"login or registration instructions to users.")), "login or registration instructions to users.")),
$this->newOption('account.editable', 'bool', true) $this->newOption('account.editable', 'bool', true)
->setOptions( ->setBoolOptions(
array( array(
pht("Allow editing"), pht("Allow editing"),
pht("Prevent editing") pht("Prevent editing")

View file

@ -9,7 +9,7 @@ final class PhabricatorConfigOption
private $summary; private $summary;
private $description; private $description;
private $type; private $type;
private $options; private $boolOptions;
private $group; private $group;
private $examples; private $examples;
private $locked; private $locked;
@ -77,13 +77,19 @@ final class PhabricatorConfigOption
return $this->group; return $this->group;
} }
public function setOptions(array $options) { public function setBoolOptions(array $options) {
$this->options = $options; $this->boolOptions = $options;
return $this; return $this;
} }
public function getOptions() { public function getBoolOptions() {
return $this->options; if ($this->boolOptions) {
return $this->boolOptions;
}
return array(
pht('True'),
pht('False'),
);
} }
public function setKey($key) { public function setKey($key) {

View file

@ -51,7 +51,7 @@ final class PhabricatorCoreConfigOptions
->addExample('America/Boise', pht('US Mountain (MDT)')) ->addExample('America/Boise', pht('US Mountain (MDT)'))
->addExample('America/Los_Angeles', pht('US West (PDT)')), ->addExample('America/Los_Angeles', pht('US West (PDT)')),
$this->newOption('phabricator.serious-business', 'bool', false) $this->newOption('phabricator.serious-business', 'bool', false)
->setOptions( ->setBoolOptions(
array( array(
pht('Serious business'), pht('Serious business'),
pht('Shenanigans'), // That should be interesting to translate. :P pht('Shenanigans'), // That should be interesting to translate. :P

View file

@ -14,7 +14,7 @@ final class PhabricatorDeveloperConfigOptions
public function getOptions() { public function getOptions() {
return array( return array(
$this->newOption('darkconsole.enabled', 'bool', false) $this->newOption('darkconsole.enabled', 'bool', false)
->setOptions( ->setBoolOptions(
array( array(
pht("Enable DarkConsole"), pht("Enable DarkConsole"),
pht("Disable DarkConsole"), pht("Disable DarkConsole"),
@ -33,7 +33,7 @@ final class PhabricatorDeveloperConfigOptions
"stack traces, and configuration) so you generally should not ". "stack traces, and configuration) so you generally should not ".
"turn it on in production.")), "turn it on in production.")),
$this->newOption('darkconsole.always-on', 'bool', false) $this->newOption('darkconsole.always-on', 'bool', false)
->setOptions( ->setBoolOptions(
array( array(
pht("Always Activate DarkConsole"), pht("Always Activate DarkConsole"),
pht("Require DarkConsole Activation"), pht("Require DarkConsole Activation"),
@ -48,7 +48,7 @@ final class PhabricatorDeveloperConfigOptions
"You must enable DarkConsole by setting {{darkconsole.enabled}} ". "You must enable DarkConsole by setting {{darkconsole.enabled}} ".
"before this option will have any effect.")), "before this option will have any effect.")),
$this->newOption('debug.stop-on-redirect', 'bool', false) $this->newOption('debug.stop-on-redirect', 'bool', false)
->setOptions( ->setBoolOptions(
array( array(
pht("Stop Before HTTP Redirect"), pht("Stop Before HTTP Redirect"),
pht("Use Normal HTTP Redirects"), pht("Use Normal HTTP Redirects"),
@ -87,7 +87,7 @@ final class PhabricatorDeveloperConfigOptions
"set it to 1 in order to debug performance problems.\n\n". "set it to 1 in order to debug performance problems.\n\n".
"NOTE: You must install XHProf for profiling to work.")), "NOTE: You must install XHProf for profiling to work.")),
$this->newOption('phabricator.show-stack-traces', 'bool', false) $this->newOption('phabricator.show-stack-traces', 'bool', false)
->setOptions( ->setBoolOptions(
array( array(
pht('Show stack traces'), pht('Show stack traces'),
pht('Hide stack traces'), pht('Hide stack traces'),
@ -99,7 +99,7 @@ final class PhabricatorDeveloperConfigOptions
"default. You can enable traces for development to make it easier ". "default. You can enable traces for development to make it easier ".
"to debug problems.")), "to debug problems.")),
$this->newOption('phabricator.show-error-callout', 'bool', false) $this->newOption('phabricator.show-error-callout', 'bool', false)
->setOptions( ->setBoolOptions(
array( array(
pht('Show error callout'), pht('Show error callout'),
pht('Hide error callout'), pht('Hide error callout'),
@ -112,7 +112,7 @@ final class PhabricatorDeveloperConfigOptions
"developing Phabricator. A callout is simply a red error at the ". "developing Phabricator. A callout is simply a red error at the ".
"top of the page.")), "top of the page.")),
$this->newOption('celerity.force-disk-reads', 'bool', false) $this->newOption('celerity.force-disk-reads', 'bool', false)
->setOptions( ->setBoolOptions(
array( array(
pht('Force disk reads'), pht('Force disk reads'),
pht("Don't force disk reads"), pht("Don't force disk reads"),
@ -129,7 +129,7 @@ final class PhabricatorDeveloperConfigOptions
"performance improve with it off) but turn it on in development. ". "performance improve with it off) but turn it on in development. ".
"(These settings are the defaults.)")), "(These settings are the defaults.)")),
$this->newOption('celerity.minify', 'bool', false) $this->newOption('celerity.minify', 'bool', false)
->setOptions( ->setBoolOptions(
array( array(
pht('Minify static resources.'), pht('Minify static resources.'),
pht("Don't minify static resources."), pht("Don't minify static resources."),

View file

@ -14,7 +14,7 @@ final class PhabricatorDisqusConfigOptions
public function getOptions() { public function getOptions() {
return array( return array(
$this->newOption('disqus.auth-enabled', 'bool', false) $this->newOption('disqus.auth-enabled', 'bool', false)
->setOptions( ->setBoolOptions(
array( array(
pht("Enable Disqus Authentication"), pht("Enable Disqus Authentication"),
pht("Disable Disqus Authentication"), pht("Disable Disqus Authentication"),
@ -23,7 +23,7 @@ final class PhabricatorDisqusConfigOptions
pht( pht(
'Allow users to login to Phabricator using Disqus credentials.')), 'Allow users to login to Phabricator using Disqus credentials.')),
$this->newOption('disqus.registration-enabled', 'bool', true) $this->newOption('disqus.registration-enabled', 'bool', true)
->setOptions( ->setBoolOptions(
array( array(
pht("Enable Disqus Registration"), pht("Enable Disqus Registration"),
pht("Disable Disqus Registration"), pht("Disable Disqus Registration"),
@ -33,7 +33,7 @@ final class PhabricatorDisqusConfigOptions
'Allow users to create new Phabricator accounts using Disqus '. 'Allow users to create new Phabricator accounts using Disqus '.
'credentials.')), 'credentials.')),
$this->newOption('disqus.auth-permanent', 'bool', false) $this->newOption('disqus.auth-permanent', 'bool', false)
->setOptions( ->setBoolOptions(
array( array(
pht("Permanently Bind Disqus Accounts"), pht("Permanently Bind Disqus Accounts"),
pht("Allow Disqus Account Unlinking"), pht("Allow Disqus Account Unlinking"),

View file

@ -14,7 +14,7 @@ final class PhabricatorFacebookConfigOptions
public function getOptions() { public function getOptions() {
return array( return array(
$this->newOption('facebook.auth-enabled', 'bool', false) $this->newOption('facebook.auth-enabled', 'bool', false)
->setOptions( ->setBoolOptions(
array( array(
pht("Enable Facebook Authentication"), pht("Enable Facebook Authentication"),
pht("Disable Facebook Authentication"), pht("Disable Facebook Authentication"),
@ -23,7 +23,7 @@ final class PhabricatorFacebookConfigOptions
pht( pht(
'Allow users to login to Phabricator using Facebook credentials.')), 'Allow users to login to Phabricator using Facebook credentials.')),
$this->newOption('facebook.registration-enabled', 'bool', true) $this->newOption('facebook.registration-enabled', 'bool', true)
->setOptions( ->setBoolOptions(
array( array(
pht("Enable Facebook Registration"), pht("Enable Facebook Registration"),
pht("Disable Facebook Registration"), pht("Disable Facebook Registration"),
@ -33,7 +33,7 @@ final class PhabricatorFacebookConfigOptions
'Allow users to create new Phabricator accounts using Facebook '. 'Allow users to create new Phabricator accounts using Facebook '.
'credentials.')), 'credentials.')),
$this->newOption('facebook.auth-permanent', 'bool', false) $this->newOption('facebook.auth-permanent', 'bool', false)
->setOptions( ->setBoolOptions(
array( array(
pht("Permanently Bind Facebook Accounts"), pht("Permanently Bind Facebook Accounts"),
pht("Allow Facebook Account Unlinking"), pht("Allow Facebook Account Unlinking"),
@ -51,7 +51,7 @@ final class PhabricatorFacebookConfigOptions
pht( pht(
'Facebook "Application Secret" to use for Facebook API access.')), 'Facebook "Application Secret" to use for Facebook API access.')),
$this->newOption('facebook.require-https-auth', 'bool', false) $this->newOption('facebook.require-https-auth', 'bool', false)
->setOptions( ->setBoolOptions(
array( array(
pht("Require HTTPS"), pht("Require HTTPS"),
pht("Do Not Require HTTPS"), pht("Do Not Require HTTPS"),

View file

@ -14,7 +14,7 @@ final class PhabricatorGitHubConfigOptions
public function getOptions() { public function getOptions() {
return array( return array(
$this->newOption('github.auth-enabled', 'bool', false) $this->newOption('github.auth-enabled', 'bool', false)
->setOptions( ->setBoolOptions(
array( array(
pht("Enable GitHub Authentication"), pht("Enable GitHub Authentication"),
pht("Disable GitHub Authentication"), pht("Disable GitHub Authentication"),
@ -23,7 +23,7 @@ final class PhabricatorGitHubConfigOptions
pht( pht(
'Allow users to login to Phabricator using GitHub credentials.')), 'Allow users to login to Phabricator using GitHub credentials.')),
$this->newOption('github.registration-enabled', 'bool', true) $this->newOption('github.registration-enabled', 'bool', true)
->setOptions( ->setBoolOptions(
array( array(
pht("Enable GitHub Registration"), pht("Enable GitHub Registration"),
pht("Disable GitHub Registration"), pht("Disable GitHub Registration"),
@ -33,7 +33,7 @@ final class PhabricatorGitHubConfigOptions
'Allow users to create new Phabricator accounts using GitHub '. 'Allow users to create new Phabricator accounts using GitHub '.
'credentials.')), 'credentials.')),
$this->newOption('github.auth-permanent', 'bool', false) $this->newOption('github.auth-permanent', 'bool', false)
->setOptions( ->setBoolOptions(
array( array(
pht("Permanently Bind GitHub Accounts"), pht("Permanently Bind GitHub Accounts"),
pht("Allow GitHub Account Unlinking"), pht("Allow GitHub Account Unlinking"),

View file

@ -14,7 +14,7 @@ final class PhabricatorGoogleConfigOptions
public function getOptions() { public function getOptions() {
return array( return array(
$this->newOption('google.auth-enabled', 'bool', false) $this->newOption('google.auth-enabled', 'bool', false)
->setOptions( ->setBoolOptions(
array( array(
pht("Enable Google Authentication"), pht("Enable Google Authentication"),
pht("Disable Google Authentication"), pht("Disable Google Authentication"),
@ -23,7 +23,7 @@ final class PhabricatorGoogleConfigOptions
pht( pht(
'Allow users to login to Phabricator using Google credentials.')), 'Allow users to login to Phabricator using Google credentials.')),
$this->newOption('google.registration-enabled', 'bool', true) $this->newOption('google.registration-enabled', 'bool', true)
->setOptions( ->setBoolOptions(
array( array(
pht("Enable Google Registration"), pht("Enable Google Registration"),
pht("Disable Google Registration"), pht("Disable Google Registration"),
@ -33,7 +33,7 @@ final class PhabricatorGoogleConfigOptions
'Allow users to create new Phabricator accounts using Google '. 'Allow users to create new Phabricator accounts using Google '.
'credentials.')), 'credentials.')),
$this->newOption('google.auth-permanent', 'bool', false) $this->newOption('google.auth-permanent', 'bool', false)
->setOptions( ->setBoolOptions(
array( array(
pht("Permanently Bind Google Accounts"), pht("Permanently Bind Google Accounts"),
pht("Allow Google Account Unlinking"), pht("Allow Google Account Unlinking"),

View file

@ -14,7 +14,7 @@ final class PhabricatorLDAPConfigOptions
public function getOptions() { public function getOptions() {
return array( return array(
$this->newOption('ldap.auth-enabled', 'bool', false) $this->newOption('ldap.auth-enabled', 'bool', false)
->setOptions( ->setBoolOptions(
array( array(
pht("Enable LDAP Authentication"), pht("Enable LDAP Authentication"),
pht("Disable LDAP Authentication"), pht("Disable LDAP Authentication"),
@ -39,7 +39,7 @@ final class PhabricatorLDAPConfigOptions
->setDescription(pht('LDAP base domain name.')), ->setDescription(pht('LDAP base domain name.')),
$this->newOption('ldap.search_attribute', 'string', null), $this->newOption('ldap.search_attribute', 'string', null),
$this->newOption('ldap.search-first', 'bool', false) $this->newOption('ldap.search-first', 'bool', false)
->setOptions( ->setBoolOptions(
array( array(
pht("Enabled"), pht("Enabled"),
pht("Disabled"), pht("Disabled"),
@ -54,7 +54,7 @@ final class PhabricatorLDAPConfigOptions
$this->newOption('ldap.activedirectory_domain', 'string', null), $this->newOption('ldap.activedirectory_domain', 'string', null),
$this->newOption('ldap.version', 'int', 3), $this->newOption('ldap.version', 'int', 3),
$this->newOption('ldap.referrals', 'bool', true) $this->newOption('ldap.referrals', 'bool', true)
->setOptions( ->setBoolOptions(
array( array(
pht("Follow Referrals"), pht("Follow Referrals"),
pht("Do Not Follow Referrals"), pht("Do Not Follow Referrals"),

View file

@ -14,7 +14,7 @@ final class PhabricatorNotificationConfigOptions
public function getOptions() { public function getOptions() {
return array( return array(
$this->newOption('notification.enabled', 'bool', false) $this->newOption('notification.enabled', 'bool', false)
->setOptions( ->setBoolOptions(
array( array(
pht("Enable Real-Time Notifications"), pht("Enable Real-Time Notifications"),
pht("Disable Real-Time Notifications"), pht("Disable Real-Time Notifications"),

View file

@ -14,7 +14,7 @@ final class PhabricatorPolicyConfigOptions
public function getOptions() { public function getOptions() {
return array( return array(
$this->newOption('policy.allow-public', 'bool', false) $this->newOption('policy.allow-public', 'bool', false)
->setOptions( ->setBoolOptions(
array( array(
pht('Allow Public Visibility'), pht('Allow Public Visibility'),
pht('Require Login'))) pht('Require Login')))

View file

@ -15,7 +15,7 @@ final class PhabricatorRecaptchaConfigOptions
return array( return array(
$this->newOption('recaptcha.enabled', 'bool', false) $this->newOption('recaptcha.enabled', 'bool', false)
->setOptions( ->setBoolOptions(
array( array(
pht("Enable Recaptcha"), pht("Enable Recaptcha"),
pht("Disable Recaptcha"), pht("Disable Recaptcha"),

View file

@ -73,7 +73,7 @@ final class PhabricatorSecurityConfigOptions
"connection type. Alternatively, you can add a PHP snippet to ". "connection type. Alternatively, you can add a PHP snippet to ".
"the top of this configuration file to directly set ". "the top of this configuration file to directly set ".
"\$_SERVER['HTTPS'] to the correct value.")) "\$_SERVER['HTTPS'] to the correct value."))
->setOptions( ->setBoolOptions(
array( array(
pht('Force HTTPS'), pht('Force HTTPS'),
pht('Allow HTTP'), pht('Allow HTTP'),

View file

@ -14,7 +14,7 @@ final class PhabricatorDifferentialConfigOptions
public function getOptions() { public function getOptions() {
return array( return array(
$this->newOption('differential.show-host-field', 'bool', false) $this->newOption('differential.show-host-field', 'bool', false)
->setOptions( ->setBoolOptions(
array( array(
pht('Disable "Host" Fields'), pht('Disable "Host" Fields'),
pht('Show "Host" Fields'), pht('Show "Host" Fields'),
@ -30,7 +30,7 @@ final class PhabricatorDifferentialConfigOptions
'development machines. You can set this option to true to enable '. 'development machines. You can set this option to true to enable '.
'these fields.')), 'these fields.')),
$this->newOption('differential.show-test-plan-field', 'bool', true) $this->newOption('differential.show-test-plan-field', 'bool', true)
->setOptions( ->setBoolOptions(
array( array(
pht('Hide "Test Plan" Field'), pht('Hide "Test Plan" Field'),
pht('Show "Test Plan" Field'), pht('Show "Test Plan" Field'),
@ -45,7 +45,7 @@ final class PhabricatorDifferentialConfigOptions
'here. You can also make it optional (instead of required) by '. 'here. You can also make it optional (instead of required) by '.
'setting {{differential.require-test-plan-field}}.')), 'setting {{differential.require-test-plan-field}}.')),
$this->newOption('differential.enable-email-accept', 'bool', false) $this->newOption('differential.enable-email-accept', 'bool', false)
->setOptions( ->setBoolOptions(
array( array(
pht('Disable Email "!accept" Action'), pht('Disable Email "!accept" Action'),
pht('Enable Email "!accept" Action'), pht('Enable Email "!accept" Action'),