@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhabricatorProjectColumnLimitTransaction
4 extends PhabricatorProjectColumnTransactionType {
5
6 const TRANSACTIONTYPE = 'project:col:limit';
7
8 public function generateOldValue($object) {
9 return $object->getPointLimit();
10 }
11
12 public function generateNewValue($object, $value) {
13 if (strlen($value)) {
14 return (int)$value;
15 } else {
16 return null;
17 }
18 }
19
20 public function applyInternalEffects($object, $value) {
21 $object->setPointLimit($value);
22 }
23
24 public function getTitle() {
25 $old = $this->getOldValue();
26 $new = $this->getNewValue();
27
28 if (!$old) {
29 return pht(
30 '%s set the point limit for this column to %s.',
31 $this->renderAuthor(),
32 $this->renderNewValue());
33 } else if (!$new) {
34 return pht(
35 '%s removed the point limit for this column.',
36 $this->renderAuthor());
37 } else {
38 return pht(
39 '%s changed the point limit for this column from %s to %s.',
40 $this->renderAuthor(),
41 $this->renderOldValue(),
42 $this->renderNewValue());
43 }
44 }
45
46 public function validateTransactions($object, array $xactions) {
47 $errors = array();
48
49 foreach ($xactions as $xaction) {
50 $value = $xaction->getNewValue();
51 if (strlen($value) && !preg_match('/^\d+\z/', $value)) {
52 $errors[] = $this->newInvalidError(
53 pht(
54 'Column point limit must either be empty or a nonnegative '.
55 'integer.'),
56 $xaction);
57 }
58 }
59
60 return $errors;
61 }
62
63}