Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/dashboard/xaction/panel/PhabricatorDashboardPanelNameTransaction.php
13459 views
1
<?php
2
3
final class PhabricatorDashboardPanelNameTransaction
4
extends PhabricatorDashboardPanelTransactionType {
5
6
const TRANSACTIONTYPE = 'dashpanel: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
$old = $this->getOldValue();
18
$new = $this->getNewValue();
19
20
return pht(
21
'%s renamed this panel from %s to %s.',
22
$this->renderAuthor(),
23
$this->renderOldValue(),
24
$this->renderNewValue());
25
}
26
27
public function validateTransactions($object, array $xactions) {
28
$errors = array();
29
30
$max_length = $object->getColumnMaximumByteLength('name');
31
foreach ($xactions as $xaction) {
32
$new = $xaction->getNewValue();
33
if (!strlen($new)) {
34
$errors[] = $this->newInvalidError(
35
pht('Panels must have a title.'),
36
$xaction);
37
continue;
38
}
39
40
if (strlen($new) > $max_length) {
41
$errors[] = $this->newInvalidError(
42
pht(
43
'Panel names must not be longer than %s characters.',
44
$max_length));
45
continue;
46
}
47
}
48
49
if (!$errors) {
50
if ($this->isEmptyTextTransaction($object->getName(), $xactions)) {
51
$errors[] = $this->newRequiredError(
52
pht('Panels must have a title.'));
53
}
54
}
55
56
return $errors;
57
}
58
59
public function getTransactionTypeForConduit($xaction) {
60
return 'name';
61
}
62
63
public function getFieldValuesForConduit($xaction, $data) {
64
return array(
65
'old' => $xaction->getOldValue(),
66
'new' => $xaction->getNewValue(),
67
);
68
}
69
70
}
71
72