Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/packages/xaction/publisher/PhabricatorPackagesPublisherKeyTransaction.php
12242 views
1
<?php
2
3
final class PhabricatorPackagesPublisherKeyTransaction
4
extends PhabricatorPackagesPublisherTransactionType {
5
6
const TRANSACTIONTYPE = 'packages.publisher.key';
7
8
public function generateOldValue($object) {
9
return $object->getPublisherKey();
10
}
11
12
public function applyInternalEffects($object, $value) {
13
$object->setPublisherKey($value);
14
}
15
16
public function validateTransactions($object, array $xactions) {
17
$errors = array();
18
19
if ($this->isEmptyTextTransaction($object->getName(), $xactions)) {
20
$errors[] = $this->newRequiredError(
21
pht('Publishers must have a unique publisher key.'));
22
}
23
24
if (!$this->isNewObject()) {
25
foreach ($xactions as $xaction) {
26
$errors[] = $this->newInvalidError(
27
pht('Once a publisher is created, its key can not be changed.'),
28
$xaction);
29
}
30
}
31
32
foreach ($xactions as $xaction) {
33
$value = $xaction->getNewValue();
34
try {
35
PhabricatorPackagesPublisher::assertValidPublisherKey($value);
36
} catch (Exception $ex) {
37
$errors[] = $this->newInvalidError($ex->getMessage(), $xaction);
38
}
39
}
40
41
return $errors;
42
}
43
44
}
45
46