3 final class ManiphestTaskPointsTransaction
4 extends ManiphestTaskTransactionType
{
6 const TRANSACTIONTYPE
= 'points';
8 public function generateOldValue($object) {
9 return $this->getValueForPoints($object->getPoints());
12 public function generateNewValue($object, $value) {
13 return $this->getValueForPoints($value);
16 public function applyInternalEffects($object, $value) {
17 $object->setPoints($value);
20 public function shouldHide() {
21 if (!ManiphestTaskPoints
::getIsEnabled()) {
27 public function getTitle() {
28 $old = $this->getOldValue();
29 $new = $this->getNewValue();
33 '%s set the point value for this task to %s.',
34 $this->renderAuthor(),
35 $this->renderNewValue());
36 } else if ($new === null) {
38 '%s removed the point value for this task.',
39 $this->renderAuthor());
42 '%s changed the point value for this task from %s to %s.',
43 $this->renderAuthor(),
44 $this->renderOldValue(),
45 $this->renderNewValue());
49 public function getTitleForFeed() {
50 $old = $this->getOldValue();
51 $new = $this->getNewValue();
55 '%s set the point value for %s to %s.',
56 $this->renderAuthor(),
57 $this->renderObject(),
58 $this->renderNewValue());
59 } else if ($new === null) {
61 '%s removed the point value for %s.',
62 $this->renderAuthor(),
63 $this->renderObject());
66 '%s changed the point value for %s from %s to %s.',
67 $this->renderAuthor(),
68 $this->renderObject(),
69 $this->renderOldValue(),
70 $this->renderNewValue());
75 public function validateTransactions($object, array $xactions) {
78 foreach ($xactions as $xaction) {
79 $new = $xaction->getNewValue();
80 if (strlen($new) && !is_numeric($new)) {
81 $errors[] = $this->newInvalidError(
82 pht('Points value must be numeric or empty.'));
86 if ((double)$new < 0) {
87 $errors[] = $this->newInvalidError(
88 pht('Points value must be nonnegative.'));
96 public function getIcon() {
97 return 'fa-calculator';
100 private function getValueForPoints($value) {
101 if ($value !== null && !strlen($value)) {
104 if ($value !== null) {
105 $value = (double)$value;
110 public function getTransactionTypeForConduit($xaction) {
114 public function getFieldValuesForConduit($xaction, $data) {
116 'old' => $xaction->getOldValue(),
117 'new' => $xaction->getNewValue(),