3 final class PhabricatorCalendarExportModeTransaction
4 extends PhabricatorCalendarExportTransactionType
{
6 const TRANSACTIONTYPE
= 'calendar.export.mode';
8 public function generateOldValue($object) {
9 return $object->getPolicyMode();
12 public function applyInternalEffects($object, $value) {
13 $object->setPolicyMode($value);
16 public function getTitle() {
17 $old_value = $this->getOldValue();
18 $new_value = $this->getNewValue();
20 $old_name = PhabricatorCalendarExport
::getPolicyModeName($old_value);
21 $new_name = PhabricatorCalendarExport
::getPolicyModeName($new_value);
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));
30 public function validateTransactions($object, array $xactions) {
33 $valid = PhabricatorCalendarExport
::getPolicyModes();
34 $valid = array_fuse($valid);
36 foreach ($xactions as $xaction) {
37 $value = $xaction->getNewValue();
39 if (isset($valid[$value])) {
43 $errors[] = $this->newInvalidError(
45 'Mode "%s" is not a valid policy mode. Valid modes are: %s.',
47 implode(', ', $valid)),