Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F101485619
PhabricatorProjectTriggerManiphestPriorityRule.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, Feb 10, 22:18
Size
2 KB
Mime Type
text/x-php
Expires
Wed, Feb 12, 22:18 (2 d)
Engine
blob
Format
Raw Data
Handle
24161920
Attached To
rPH Phabricator
PhabricatorProjectTriggerManiphestPriorityRule.php
View Options
<?php
final
class
PhabricatorProjectTriggerManiphestPriorityRule
extends
PhabricatorProjectTriggerRule
{
const
TRIGGERTYPE
=
'task.priority'
;
public
function
getSelectControlName
()
{
return
pht
(
'Change priority to'
);
}
protected
function
assertValidRuleValue
(
$value
)
{
if
(!
is_string
(
$value
))
{
throw
new
Exception
(
pht
(
'Priority rule value should be a string, but is not (value is "%s").'
,
phutil_describe_type
(
$value
)));
}
$map
=
ManiphestTaskPriority
::
getTaskPriorityMap
();
if
(!
isset
(
$map
[
$value
]))
{
throw
new
Exception
(
pht
(
'Rule value ("%s") is not a valid task priority.'
,
$value
));
}
}
protected
function
newDropTransactions
(
$object
,
$value
)
{
$value
=
ManiphestTaskPriority
::
getKeywordForTaskPriority
(
$value
);
return
array
(
$this
->
newTransaction
()
->
setTransactionType
(
ManiphestTaskPriorityTransaction
::
TRANSACTIONTYPE
)
->
setNewValue
(
$value
),
);
}
protected
function
newDropEffects
(
$value
)
{
$priority_name
=
ManiphestTaskPriority
::
getTaskPriorityName
(
$value
);
$priority_icon
=
ManiphestTaskPriority
::
getTaskPriorityIcon
(
$value
);
$priority_color
=
ManiphestTaskPriority
::
getTaskPriorityColor
(
$value
);
$content
=
pht
(
'Change priority to %s.'
,
phutil_tag
(
'strong'
,
array
(),
$priority_name
));
return
array
(
$this
->
newEffect
()
->
setIcon
(
$priority_icon
)
->
setColor
(
$priority_color
)
->
addCondition
(
'priority'
,
'!='
,
$value
)
->
setContent
(
$content
),
);
}
protected
function
getDefaultValue
()
{
return
head_key
(
ManiphestTaskPriority
::
getTaskPriorityMap
());
}
protected
function
getPHUIXControlType
()
{
return
'select'
;
}
protected
function
getPHUIXControlSpecification
()
{
$map
=
ManiphestTaskPriority
::
getTaskPriorityMap
();
return
array
(
'options'
=>
$map
,
'order'
=>
array_keys
(
$map
),
);
}
public
function
getRuleViewLabel
()
{
return
pht
(
'Change Priority'
);
}
public
function
getRuleViewDescription
(
$value
)
{
$priority_name
=
ManiphestTaskPriority
::
getTaskPriorityName
(
$value
);
return
pht
(
'Change task priority to %s.'
,
phutil_tag
(
'strong'
,
array
(),
$priority_name
));
}
public
function
getRuleViewIcon
(
$value
)
{
$priority_icon
=
ManiphestTaskPriority
::
getTaskPriorityIcon
(
$value
);
$priority_color
=
ManiphestTaskPriority
::
getTaskPriorityColor
(
$value
);
return
id
(
new
PHUIIconView
())
->
setIcon
(
$priority_icon
,
$priority_color
);
}
}
Event Timeline
Log In to Comment