Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/owners/xaction/PhabricatorOwnersPackageAutoreviewTransaction.php
12256 views
1
<?php
2
3
final class PhabricatorOwnersPackageAutoreviewTransaction
4
extends PhabricatorOwnersPackageTransactionType {
5
6
const TRANSACTIONTYPE = 'owners.autoreview';
7
8
public function generateOldValue($object) {
9
return $object->getAutoReview();
10
}
11
12
public function validateTransactions($object, array $xactions) {
13
$errors = array();
14
15
$map = PhabricatorOwnersPackage::getAutoreviewOptionsMap();
16
foreach ($xactions as $xaction) {
17
$new = $xaction->getNewValue();
18
19
if (empty($map[$new])) {
20
$valid = array_keys($map);
21
22
$errors[] = $this->newInvalidError(
23
pht(
24
'Autoreview setting "%s" is not valid. '.
25
'Valid settings are: %s.',
26
$new,
27
implode(', ', $valid)),
28
$xaction);
29
}
30
}
31
32
return $errors;
33
}
34
35
public function applyInternalEffects($object, $value) {
36
$object->setAutoReview($value);
37
}
38
39
public function getTitle() {
40
$map = PhabricatorOwnersPackage::getAutoreviewOptionsMap();
41
$map = ipull($map, 'name');
42
43
$old = $this->getOldValue();
44
$new = $this->getNewValue();
45
46
$old = idx($map, $old, $old);
47
$new = idx($map, $new, $new);
48
49
return pht(
50
'%s adjusted autoreview from %s to %s.',
51
$this->renderAuthor(),
52
$this->renderValue($old),
53
$this->renderValue($new));
54
}
55
56
}
57
58