Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F3281632
ManiphestTaskPointsTransaction.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
3 KB
Referenced Files
None
Subscribers
None
ManiphestTaskPointsTransaction.php
View Options
<?php
final
class
ManiphestTaskPointsTransaction
extends
ManiphestTaskTransactionType
{
const
TRANSACTIONTYPE
=
'points'
;
public
function
generateOldValue
(
$object
)
{
return
$this
->
getValueForPoints
(
$object
->
getPoints
(
)
)
;
}
public
function
generateNewValue
(
$object
,
$value
)
{
return
$this
->
getValueForPoints
(
$value
)
;
}
public
function
applyInternalEffects
(
$object
,
$value
)
{
$object
->
setPoints
(
$value
)
;
}
public
function
shouldHide
(
)
{
if
(
!
ManiphestTaskPoints
::
getIsEnabled
(
)
)
{
return
true
;
}
return
false
;
}
public
function
getTitle
(
)
{
$old
=
$this
->
getOldValue
(
)
;
$new
=
$this
->
getNewValue
(
)
;
if
(
$old
===
null
)
{
return
pht
(
'%s set the point value for this task to %s.'
,
$this
->
renderAuthor
(
)
,
$this
->
renderNewValue
(
)
)
;
}
else
if
(
$new
===
null
&&
$old
!==
null
)
{
return
pht
(
'%s removed the point value %s for this task.'
,
$this
->
renderAuthor
(
)
,
$this
->
renderOldValue
(
)
)
;
}
else
if
(
$new
===
null
)
{
return
pht
(
'%s removed the point value for this task.'
,
$this
->
renderAuthor
(
)
)
;
}
else
{
return
pht
(
'%s changed the point value for this task from %s to %s.'
,
$this
->
renderAuthor
(
)
,
$this
->
renderOldValue
(
)
,
$this
->
renderNewValue
(
)
)
;
}
}
public
function
getTitleForFeed
(
)
{
$old
=
$this
->
getOldValue
(
)
;
$new
=
$this
->
getNewValue
(
)
;
if
(
$old
===
null
)
{
return
pht
(
'%s set the point value for %s to %s.'
,
$this
->
renderAuthor
(
)
,
$this
->
renderObject
(
)
,
$this
->
renderNewValue
(
)
)
;
}
else
if
(
$new
===
null
)
{
return
pht
(
'%s removed the point value for %s.'
,
$this
->
renderAuthor
(
)
,
$this
->
renderObject
(
)
)
;
}
else
{
return
pht
(
'%s changed the point value for %s from %s to %s.'
,
$this
->
renderAuthor
(
)
,
$this
->
renderObject
(
)
,
$this
->
renderOldValue
(
)
,
$this
->
renderNewValue
(
)
)
;
}
}
public
function
validateTransactions
(
$object
,
array
$xactions
)
{
$errors
=
array
(
)
;
foreach
(
$xactions
as
$xaction
)
{
$new
=
$xaction
->
getNewValue
(
)
;
if
(
phutil_nonempty_string
(
$new
)
&&
!
is_numeric
(
$new
)
)
{
$errors
[
]
=
$this
->
newInvalidError
(
pht
(
'Points value must be numeric or empty.'
)
)
;
continue
;
}
if
(
(double)
$new
<
0
)
{
$errors
[
]
=
$this
->
newInvalidError
(
pht
(
'Points value must be nonnegative.'
)
)
;
continue
;
}
}
return
$errors
;
}
public
function
getIcon
(
)
{
return
'fa-calculator'
;
}
/**
* Normalize your Story Points from generic stuff to double or null.
* @param mixed $value Your raw Story Points
* @return double|null
*/
private
function
getValueForPoints
(
$value
)
{
// The Point can be various types also thanks to Conduit API
// like integers, floats, null, and strings of course.
// Everything meaningful must be printable as a string.
$is_empty
=
phutil_string_cast
(
$value
)
===
''
;
if
(
$is_empty
)
{
$value
=
null
;
}
if
(
$value
!==
null
)
{
$value
=
(double)
$value
;
}
return
$value
;
}
public
function
getTransactionTypeForConduit
(
$xaction
)
{
return
'points'
;
}
public
function
getFieldValuesForConduit
(
$xaction
,
$data
)
{
return
array
(
'old'
=>
$xaction
->
getOldValue
(
)
,
'new'
=>
$xaction
->
getNewValue
(
)
,
)
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, Mar 24, 00:22 (1 d, 5 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1116348
Default Alt Text
ManiphestTaskPointsTransaction.php (3 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment