@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 PhabricatorCountdownTitleTransaction
4 extends PhabricatorCountdownTransactionType {
5
6 const TRANSACTIONTYPE = 'countdown:title';
7
8 public function generateOldValue($object) {
9 return $object->getTitle();
10 }
11
12 public function applyInternalEffects($object, $value) {
13 $object->setTitle($value);
14 }
15
16 public function getTitle() {
17 return pht(
18 '%s updated the title for this countdown from %s to %s.',
19 $this->renderAuthor(),
20 $this->renderOldValue(),
21 $this->renderNewValue());
22 }
23
24 public function getTitleForFeed() {
25 return pht(
26 '%s updated the title for this countdown from %s to %s.',
27 $this->renderAuthor(),
28 $this->renderOldValue(),
29 $this->renderNewValue());
30 }
31
32 public function validateTransactions($object, array $xactions) {
33 $errors = array();
34
35 if ($this->isEmptyTextTransaction($object->getTitle(), $xactions)) {
36 $errors[] = $this->newRequiredError(pht('Countdowns must have a title.'));
37 }
38
39 $max_length = $object->getColumnMaximumByteLength('title');
40 foreach ($xactions as $xaction) {
41 $new_value = $xaction->getNewValue();
42 $new_length = strlen($new_value);
43 if ($new_length > $max_length) {
44 $errors[] = $this->newInvalidError(
45 pht(
46 'Countdown titles must not be longer than %s characters.',
47 new PhutilNumber($max_length)));
48 }
49 }
50
51 return $errors;
52 }
53
54}