Correct Aphlict websocket URI construction after PHP8 compatibility changes
[phabricator.git] / src / applications / calendar / xaction / PhabricatorCalendarExportModeTransaction.php
bloba7214284372f50eee5daddbf75fc44ef6df50836
1 <?php
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);
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));
30 public function validateTransactions($object, array $xactions) {
31 $errors = array();
33 $valid = PhabricatorCalendarExport::getPolicyModes();
34 $valid = array_fuse($valid);
36 foreach ($xactions as $xaction) {
37 $value = $xaction->getNewValue();
39 if (isset($valid[$value])) {
40 continue;
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);
51 return $errors;