Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F101312910
PhabricatorBadgesBadgeQualityTransaction.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
Fri, Feb 7, 16:53
Size
1 KB
Mime Type
text/x-php
Expires
Sun, Feb 9, 16:53 (1 d, 20 h)
Engine
blob
Format
Raw Data
Handle
24132245
Attached To
rPH Phabricator
PhabricatorBadgesBadgeQualityTransaction.php
View Options
<?php
final
class
PhabricatorBadgesBadgeQualityTransaction
extends
PhabricatorBadgesBadgeTransactionType
{
const
TRANSACTIONTYPE
=
'badge.quality'
;
public
function
generateOldValue
(
$object
)
{
return
$object
->
getQuality
();
}
public
function
applyInternalEffects
(
$object
,
$value
)
{
$object
->
setQuality
(
$value
);
}
public
function
shouldHide
()
{
if
(
$this
->
isCreateTransaction
())
{
return
true
;
}
return
false
;
}
public
function
getTitle
()
{
$old
=
$this
->
getQualityLabel
(
$this
->
getOldValue
());
$new
=
$this
->
getQualityLabel
(
$this
->
getNewValue
());
return
pht
(
'%s updated the quality from %s to %s.'
,
$this
->
renderAuthor
(),
$old
,
$new
);
}
public
function
getTitleForFeed
()
{
$old
=
$this
->
getQualityLabel
(
$this
->
getOldValue
());
$new
=
$this
->
getQualityLabel
(
$this
->
getNewValue
());
return
pht
(
'%s updated %s quality from %s to %s.'
,
$this
->
renderAuthor
(),
$this
->
renderObject
(),
$new
,
$old
);
}
public
function
validateTransactions
(
$object
,
array
$xactions
)
{
$errors
=
array
();
if
(
$this
->
isEmptyTextTransaction
(
$object
->
getQuality
(),
$xactions
))
{
$errors
[]
=
$this
->
newRequiredError
(
pht
(
'Badge quality must be set.'
));
}
$map
=
PhabricatorBadgesQuality
::
getQualityMap
();
if
(!
$map
[
$object
->
getQuality
()])
{
$errors
[]
=
$this
->
newRequiredError
(
pht
(
'Badge quality is not valid.'
));
}
return
$errors
;
}
private
function
getQualityLabel
(
$quality
)
{
$map
=
PhabricatorBadgesQuality
::
getQualityMap
();
$name
=
$map
[
$quality
][
'name'
];
return
$this
->
renderValue
(
$name
);
}
}
Event Timeline
Log In to Comment