Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/countdown/xaction/PhabricatorCountdownTitleTransaction.php
12256 views
1
<?php
2
3
final 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 character(s).',
47
new PhutilNumber($max_length)));
48
}
49
}
50
51
return $errors;
52
}
53
54
}
55
56