Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/calendar/xaction/PhabricatorCalendarExportModeTransaction.php
12256 views
1
<?php
2
3
final class PhabricatorCalendarExportModeTransaction
4
extends PhabricatorCalendarExportTransactionType {
5
6
const TRANSACTIONTYPE = 'calendar.export.mode';
7
8
public function generateOldValue($object) {
9
return $object->getPolicyMode();
10
}
11
12
public function applyInternalEffects($object, $value) {
13
$object->setPolicyMode($value);
14
}
15
16
public function getTitle() {
17
$old_value = $this->getOldValue();
18
$new_value = $this->getNewValue();
19
20
$old_name = PhabricatorCalendarExport::getPolicyModeName($old_value);
21
$new_name = PhabricatorCalendarExport::getPolicyModeName($new_value);
22
23
return pht(
24
'%s changed the policy mode for this export from %s to %s.',
25
$this->renderAuthor(),
26
$this->renderValue($old_name),
27
$this->renderValue($new_name));
28
}
29
30
public function validateTransactions($object, array $xactions) {
31
$errors = array();
32
33
$valid = PhabricatorCalendarExport::getPolicyModes();
34
$valid = array_fuse($valid);
35
36
foreach ($xactions as $xaction) {
37
$value = $xaction->getNewValue();
38
39
if (isset($valid[$value])) {
40
continue;
41
}
42
43
$errors[] = $this->newInvalidError(
44
pht(
45
'Mode "%s" is not a valid policy mode. Valid modes are: %s.',
46
$value,
47
implode(', ', $valid)),
48
$xaction);
49
}
50
51
return $errors;
52
}
53
54
}
55
56