Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F96296060
ReleephRiskFieldSpecification.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
Tue, Dec 24, 18:03
Size
1 KB
Mime Type
text/x-php
Expires
Thu, Dec 26, 18:03 (2 d)
Engine
blob
Format
Raw Data
Handle
23151828
Attached To
rPH Phabricator
ReleephRiskFieldSpecification.php
View Options
<?php
final
class
ReleephRiskFieldSpecification
extends
ReleephFieldSpecification
{
static
$defaultRisks
=
array
(
'NONE'
=>
'Completely safe to pick this request.'
,
'SOME'
=>
'There is some risk this could break things, but not much.'
,
'HIGH'
=>
'This is pretty risky, but is also very important.'
,
);
public
function
getName
()
{
return
'Riskiness'
;
}
public
function
getStorageKey
()
{
return
'risk'
;
}
public
function
renderLabelForHeaderView
()
{
return
'Riskiness'
;
}
private
$error
=
true
;
public
function
renderEditControl
(
AphrontRequest
$request
)
{
$value
=
$request
->
getStr
(
'risk'
,
$this
->
getValue
());
$buttons
=
id
(
new
AphrontFormRadioButtonControl
())
->
setLabel
(
'Riskiness'
)
->
setName
(
'risk'
)
->
setError
(
$this
->
error
)
->
setValue
(
$value
);
foreach
(
self
::
$defaultRisks
as
$value
=>
$description
)
{
$buttons
->
addButton
(
$value
,
$value
,
$description
);
}
return
$buttons
;
}
public
function
validate
(
$risk
)
{
if
(!
$risk
)
{
$this
->
error
=
'Required'
;
throw
new
ReleephFieldParseException
(
$this
,
"No risk was given, which probably means we've changed the set "
.
"of valid risks since you made this request. Please pick one."
);
}
if
(!
idx
(
self
::
$defaultRisks
,
$risk
))
{
throw
new
ReleephFieldParseException
(
$this
,
"Unknown risk '{$risk}'."
);
}
}
public
function
renderHelpForArcanist
()
{
$help
=
''
;
foreach
(
self
::
$defaultRisks
as
$name
=>
$description
)
{
$help
.=
" **{$name}**
\n
"
;
$help
.=
phutil_console_wrap
(
$description
.
"
\n
"
,
8
);
}
return
$help
;
}
}
Event Timeline
Log In to Comment