Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F93946588
PhabricatorSelectSetting.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Dec 2, 18:13
Size
1 KB
Mime Type
text/x-php
Expires
Wed, Dec 4, 18:13 (2 d)
Engine
blob
Format
Raw Data
Handle
22729735
Attached To
rPH Phabricator
PhabricatorSelectSetting.php
View Options
<?php
abstract
class
PhabricatorSelectSetting
extends
PhabricatorSetting
{
abstract
protected
function
getSelectOptions
();
final
protected
function
newCustomEditField
(
$object
)
{
$setting_key
=
$this
->
getSettingKey
();
$default_value
=
$object
->
getDefaultValue
(
$setting_key
);
$options
=
$this
->
getSelectOptions
();
if
(
isset
(
$options
[
$default_value
]))
{
$default_label
=
pht
(
'Default (%s)'
,
$options
[
$default_value
]);
}
else
{
$default_label
=
pht
(
'Default (Unknown, "%s")'
,
$default_value
);
}
$options
=
array
(
''
=>
$default_label
,
)
+
$options
;
return
$this
->
newEditField
(
$object
,
new
PhabricatorSelectEditField
())
->
setOptions
(
$options
);
}
final
public
function
validateTransactionValue
(
$value
)
{
if
(!
strlen
(
$value
))
{
return
;
}
$options
=
$this
->
getSelectOptions
();
if
(!
isset
(
$options
[
$value
]))
{
throw
new
Exception
(
pht
(
'Value "%s" is not valid for setting "%s": valid values are %s.'
,
$value
,
$this
->
getSettingName
(),
implode
(
', '
,
array_keys
(
$options
))));
}
return
;
}
public
function
getTransactionNewValue
(
$value
)
{
if
(!
strlen
(
$value
))
{
return
null
;
}
return
(
string
)
$value
;
}
}
Event Timeline
Log In to Comment