Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/nuance/xaction/NuanceQueueNameTransaction.php
12256 views
1
<?php
2
3
final class NuanceQueueNameTransaction
4
extends NuanceQueueTransactionType {
5
6
const TRANSACTIONTYPE = 'nuance.queue.name';
7
8
public function generateOldValue($object) {
9
return $object->getName();
10
}
11
12
public function applyInternalEffects($object, $value) {
13
$object->setName($value);
14
}
15
16
public function getTitle() {
17
return pht(
18
'%s renamed this queue from %s to %s.',
19
$this->renderAuthor(),
20
$this->renderOldValue(),
21
$this->renderNewValue());
22
}
23
24
public function validateTransactions($object, array $xactions) {
25
$errors = array();
26
27
if ($this->isEmptyTextTransaction($object->getName(), $xactions)) {
28
$errors[] = $this->newRequiredError(
29
pht('Queues must have a name.'));
30
}
31
32
$max_length = $object->getColumnMaximumByteLength('name');
33
foreach ($xactions as $xaction) {
34
$new_value = $xaction->getNewValue();
35
$new_length = strlen($new_value);
36
if ($new_length > $max_length) {
37
$errors[] = $this->newInvalidError(
38
pht(
39
'Queue names must not be longer than %s character(s).',
40
new PhutilNumber($max_length)));
41
}
42
}
43
44
return $errors;
45
}
46
47
}
48
49