Changeset View
Changeset View
Standalone View
Standalone View
src/applications/settings/setting/PhabricatorSelectSetting.php
Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | if (!strlen($value)) { | ||||
'Empty string is not a valid setting for "%s".', | 'Empty string is not a valid setting for "%s".', | ||||
$this->getSettingName())); | $this->getSettingName())); | ||||
} | } | ||||
$this->validateTransactionValue($value); | $this->validateTransactionValue($value); | ||||
} | } | ||||
final public function validateTransactionValue($value) { | final public function validateTransactionValue($value) { | ||||
$value = phutil_string_cast($value); | |||||
if (!strlen($value)) { | if (!strlen($value)) { | ||||
return; | return; | ||||
} | } | ||||
$options = $this->getSelectOptions(); | $options = $this->getSelectOptions(); | ||||
if (!isset($options[$value])) { | if (!isset($options[$value])) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'Value "%s" is not valid for setting "%s": valid values are %s.', | 'Value "%s" is not valid for setting "%s": valid values are %s.', | ||||
$value, | $value, | ||||
$this->getSettingName(), | $this->getSettingName(), | ||||
implode(', ', array_keys($options)))); | implode(', ', array_keys($options)))); | ||||
} | } | ||||
return; | return; | ||||
} | } | ||||
public function getTransactionNewValue($value) { | public function getTransactionNewValue($value) { | ||||
$value = phutil_string_cast($value); | |||||
if (!strlen($value)) { | if (!strlen($value)) { | ||||
return null; | return null; | ||||
} | } | ||||
return (string)$value; | return $value; | ||||
} | } | ||||
} | } |