Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/differential/xaction/DifferentialRevisionTitleTransaction.php
12256 views
1
<?php
2
3
final class DifferentialRevisionTitleTransaction
4
extends DifferentialRevisionTransactionType {
5
6
const TRANSACTIONTYPE = 'differential.revision.title';
7
const EDITKEY = 'title';
8
9
public function generateOldValue($object) {
10
return $object->getTitle();
11
}
12
13
public function applyInternalEffects($object, $value) {
14
$object->setTitle($value);
15
}
16
17
public function getTitle() {
18
return pht(
19
'%s retitled this revision from %s to %s.',
20
$this->renderAuthor(),
21
$this->renderOldValue(),
22
$this->renderNewValue());
23
}
24
25
public function getTitleForFeed() {
26
return pht(
27
'%s retitled %s from %s to %s.',
28
$this->renderAuthor(),
29
$this->renderObject(),
30
$this->renderOldValue(),
31
$this->renderNewValue());
32
}
33
34
public function validateTransactions($object, array $xactions) {
35
$errors = array();
36
37
if ($this->isEmptyTextTransaction($object->getTitle(), $xactions)) {
38
$errors[] = $this->newRequiredError(
39
pht('Revisions must have a title.'));
40
}
41
42
$max_length = $object->getColumnMaximumByteLength('title');
43
foreach ($xactions as $xaction) {
44
$new_value = $xaction->getNewValue();
45
$new_length = strlen($new_value);
46
if ($new_length > $max_length) {
47
$errors[] = $this->newInvalidError(
48
pht(
49
'Revision title is too long: the maximum length of a '.
50
'revision title is 255 bytes.'),
51
$xaction);
52
}
53
}
54
55
return $errors;
56
}
57
58
public function getTransactionTypeForConduit($xaction) {
59
return 'title';
60
}
61
62
public function getFieldValuesForConduit($xaction, $data) {
63
return array(
64
'old' => $xaction->getOldValue(),
65
'new' => $xaction->getNewValue(),
66
);
67
}
68
69
}
70
71