1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-28 01:32:42 +01:00
phorge-phorge/src/applications/badges/xaction/PhabricatorBadgesBadgeStatusTransaction.php
Chad Little 3eae9a368d Modular Transactions for Badges
Summary: Ref T12270. This converts Badges to modular transactions for editing and awarding.

Test Plan: Add Badge, edit badge, award and revoke... Still going to test this some more but feel free to comment on anything obviously wrong?

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Maniphest Tasks: T12270

Differential Revision: https://secure.phabricator.com/D17402
2017-02-23 14:22:52 -08:00

50 lines
1.2 KiB
PHP

<?php
final class PhabricatorBadgesBadgeStatusTransaction
extends PhabricatorBadgesBadgeTransactionType {
const TRANSACTIONTYPE = 'badges.status';
public function generateOldValue($object) {
return $object->getStatus();
}
public function applyInternalEffects($object, $value) {
$object->setStatus($value);
}
public function getTitle() {
if ($this->getNewValue() == PhabricatorBadgesBadge::STATUS_ARCHIVED) {
return pht(
'%s disabled this badge.',
$this->renderAuthor());
} else {
return pht(
'%s enabled this badge.',
$this->renderAuthor());
}
}
public function getTitleForFeed() {
if ($this->getNewValue() == PhabricatorBadgesBadge::STATUS_ARCHIVED) {
return pht(
'%s disabled the badge %s.',
$this->renderAuthor(),
$this->renderObject());
} else {
return pht(
'%s enabled the badge %s.',
$this->renderAuthor(),
$this->renderObject());
}
}
public function getIcon() {
if ($this->getNewValue() == PhabricatorBadgesBadge::STATUS_ARCHIVED) {
return 'fa-ban';
} else {
return 'fa-check';
}
}
}