Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / calendar / xaction / PhabricatorCalendarImportICSURITransaction.php
blob13fdbd232b9269875421998ea9ad4fda9dbb02ac
1 <?php
3 final class PhabricatorCalendarImportICSURITransaction
4 extends PhabricatorCalendarImportTransactionType {
6 const TRANSACTIONTYPE = 'calendar.import.ics.uri';
7 const PARAMKEY_URI = 'ics.uri';
9 public function generateOldValue($object) {
10 return $object->getParameter(self::PARAMKEY_URI);
13 public function applyInternalEffects($object, $value) {
14 $object->setParameter(self::PARAMKEY_URI, $value);
17 public function getTitle() {
18 // NOTE: This transaction intentionally does not disclose the actual
19 // URI.
20 return pht(
21 '%s updated the import URI.',
22 $this->renderAuthor());
25 public function validateTransactions($object, array $xactions) {
26 $viewer = $this->getActor();
27 $errors = array();
29 $ics_type = PhabricatorCalendarICSURIImportEngine::ENGINETYPE;
30 $import_type = $object->getEngine()->getImportEngineType();
31 if ($import_type != $ics_type) {
32 if (!$xactions) {
33 return $errors;
36 $errors[] = $this->newInvalidError(
37 pht(
38 'You can not attach an ICS URI to an import type other than '.
39 'an ICS URI import (type is "%s").',
40 $import_type));
42 return $errors;
45 $new_value = $object->getParameter(self::PARAMKEY_URI);
46 foreach ($xactions as $xaction) {
47 $new_value = $xaction->getNewValue();
48 if (!strlen($new_value)) {
49 continue;
52 try {
53 PhabricatorEnv::requireValidRemoteURIForFetch(
54 $new_value,
55 array(
56 'http',
57 'https',
58 ));
59 } catch (Exception $ex) {
60 $errors[] = $this->newInvalidError(
61 $ex->getMessage(),
62 $xaction);
66 if (!strlen($new_value)) {
67 $errors[] = $this->newRequiredError(
68 pht('You must select an ".ics" URI to import.'));
71 return $errors;