Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/packages/xaction/version/PhabricatorPackagesVersionNameTransaction.php
12242 views
1
<?php
2
3
final class PhabricatorPackagesVersionNameTransaction
4
extends PhabricatorPackagesVersionTransactionType {
5
6
const TRANSACTIONTYPE = 'packages.version.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 changed the name of this version 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 name for %s from %s to %s.',
27
$this->renderAuthor(),
28
$this->renderObject(),
29
$this->renderOldValue(),
30
$this->renderNewValue());
31
}
32
33
public function validateTransactions($object, array $xactions) {
34
$errors = array();
35
36
if ($this->isEmptyTextTransaction($object->getName(), $xactions)) {
37
$errors[] = $this->newRequiredError(
38
pht('Versions must have a name.'));
39
return $errors;
40
}
41
42
foreach ($xactions as $xaction) {
43
$value = $xaction->getNewValue();
44
try {
45
PhabricatorPackagesVersion::assertValidVersionName($value);
46
} catch (Exception $ex) {
47
$errors[] = $this->newInvalidError($ex->getMessage(), $xaction);
48
}
49
}
50
51
if (!$this->isNewObject()) {
52
foreach ($xactions as $xaction) {
53
$errors[] = $this->newInvalidError(
54
pht('Once a version is created, its name can not be changed.'),
55
$xaction);
56
}
57
}
58
59
return $errors;
60
}
61
62
}
63
64