Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/calendar/xaction/PhabricatorCalendarImportFrequencyTransaction.php
12256 views
1
<?php
2
3
final class PhabricatorCalendarImportFrequencyTransaction
4
extends PhabricatorCalendarImportTransactionType {
5
6
const TRANSACTIONTYPE = 'calendar.import.frequency';
7
8
public function generateOldValue($object) {
9
return $object->getTriggerFrequency();
10
}
11
12
public function applyInternalEffects($object, $value) {
13
$object->setTriggerFrequency($value);
14
}
15
16
public function getTitle() {
17
return pht(
18
'%s changed the automatic update frequency for this import.',
19
$this->renderAuthor());
20
}
21
22
public function validateTransactions($object, array $xactions) {
23
$errors = array();
24
25
$frequency_map = PhabricatorCalendarImport::getTriggerFrequencyMap();
26
$valid = array_keys($frequency_map);
27
$valid = array_fuse($valid);
28
29
foreach ($xactions as $xaction) {
30
$value = $xaction->getNewValue();
31
32
if (!isset($valid[$value])) {
33
$errors[] = $this->newInvalidError(
34
pht(
35
'Import frequency "%s" is not valid. Valid frequencies are: %s.',
36
$value,
37
implode(', ', $valid)),
38
$xaction);
39
}
40
}
41
42
return $errors;
43
}
44
45
}
46
47