Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/drydock/xaction/DrydockBlueprintNameTransaction.php
12256 views
1
<?php
2
3
final class DrydockBlueprintNameTransaction
4
extends DrydockBlueprintTransactionType {
5
6
const TRANSACTIONTYPE = 'drydock:blueprint:name';
7
8
public function generateOldValue($object) {
9
return $object->getBlueprintName();
10
}
11
12
public function applyInternalEffects($object, $value) {
13
$object->setBlueprintName($value);
14
}
15
16
public function getTitle() {
17
return pht(
18
'%s renamed this blueprint from %s to %s.',
19
$this->renderAuthor(),
20
$this->renderOldValue(),
21
$this->renderNewValue());
22
}
23
24
public function getTitleForFeed() {
25
$old = $this->getOldValue();
26
$new = $this->getNewValue();
27
28
return pht(
29
'%s renamed %s from %s to %s.',
30
$this->renderAuthor(),
31
$this->renderObject(),
32
$this->renderOldValue(),
33
$this->renderNewValue());
34
}
35
36
public function validateTransactions($object, array $xactions) {
37
$errors = array();
38
39
$name = $object->getBlueprintName();
40
if ($this->isEmptyTextTransaction($name, $xactions)) {
41
$errors[] = $this->newRequiredError(
42
pht('Blueprints must have a name.'));
43
}
44
45
$max_length = $object->getColumnMaximumByteLength('blueprintName');
46
foreach ($xactions as $xaction) {
47
$new_value = $xaction->getNewValue();
48
49
$new_length = strlen($new_value);
50
if ($new_length > $max_length) {
51
$errors[] = $this->newInvalidError(
52
pht('Blueprint names can be no longer than %s characters.',
53
new PhutilNumber($max_length)));
54
}
55
}
56
57
return $errors;
58
}
59
60
}
61
62