1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-14 19:02:41 +01:00
phorge-phorge/src/applications/herald/storage/HeraldRuleTransaction.php

93 lines
1.9 KiB
PHP
Raw Normal View History

<?php
final class HeraldRuleTransaction
extends PhabricatorApplicationTransaction {
const TYPE_EDIT = 'herald:edit';
const TYPE_DISABLE = 'herald:disable';
public function getApplicationName() {
return 'herald';
}
public function getApplicationTransactionType() {
return HeraldPHIDTypeRule::TYPECONST;
}
public function getApplicationTransactionCommentObject() {
return new HeraldRuleTransactionComment();
}
public function getColor() {
$old = $this->getOldValue();
$new = $this->getNewValue();
switch ($this->getTransactionType()) {
case self::TYPE_DISABLE:
if ($new) {
return 'red';
} else {
return 'green';
}
}
return parent::getColor();
}
public function getActionName() {
$old = $this->getOldValue();
$new = $this->getNewValue();
switch ($this->getTransactionType()) {
case self::TYPE_DISABLE:
if ($new) {
return pht('Disabled');
} else {
return pht('Enabled');
}
}
return parent::getActionName();
}
public function getIcon() {
$old = $this->getOldValue();
$new = $this->getNewValue();
switch ($this->getTransactionType()) {
case self::TYPE_DISABLE:
if ($new) {
return 'disable';
} else {
return 'enable';
}
}
return parent::getIcon();
}
public function getTitle() {
$author_phid = $this->getAuthorPHID();
$old = $this->getOldValue();
$new = $this->getNewValue();
switch ($this->getTransactionType()) {
case self::TYPE_DISABLE:
if ($new) {
return pht(
'%s disabled this rule.',
$this->renderHandleLink($author_phid));
} else {
return pht(
'%s enabled this rule.',
$this->renderHandleLink($author_phid));
}
}
return parent::getTitle();
}
}