Path: blob/master/src/applications/calendar/xaction/PhabricatorCalendarExportModeTransaction.php
12256 views
<?php12final class PhabricatorCalendarExportModeTransaction3extends PhabricatorCalendarExportTransactionType {45const TRANSACTIONTYPE = 'calendar.export.mode';67public function generateOldValue($object) {8return $object->getPolicyMode();9}1011public function applyInternalEffects($object, $value) {12$object->setPolicyMode($value);13}1415public function getTitle() {16$old_value = $this->getOldValue();17$new_value = $this->getNewValue();1819$old_name = PhabricatorCalendarExport::getPolicyModeName($old_value);20$new_name = PhabricatorCalendarExport::getPolicyModeName($new_value);2122return pht(23'%s changed the policy mode for this export from %s to %s.',24$this->renderAuthor(),25$this->renderValue($old_name),26$this->renderValue($new_name));27}2829public function validateTransactions($object, array $xactions) {30$errors = array();3132$valid = PhabricatorCalendarExport::getPolicyModes();33$valid = array_fuse($valid);3435foreach ($xactions as $xaction) {36$value = $xaction->getNewValue();3738if (isset($valid[$value])) {39continue;40}4142$errors[] = $this->newInvalidError(43pht(44'Mode "%s" is not a valid policy mode. Valid modes are: %s.',45$value,46implode(', ', $valid)),47$xaction);48}4950return $errors;51}5253}545556