Remove all "FileHasObject" edge reads and writes
[phabricator.git] / src / applications / calendar / worker / PhabricatorCalendarImportReloadWorker.php
blob8f27a814ab41c0c6afcb8ef1b492b54e3ded9364
1 <?php
3 final class PhabricatorCalendarImportReloadWorker extends PhabricatorWorker {
5 const VIA_TRIGGER = 'trigger';
6 const VIA_BACKGROUND = 'background';
8 protected function doWork() {
9 $import = $this->loadImport();
10 $viewer = PhabricatorUser::getOmnipotentUser();
12 if ($import->getIsDisabled()) {
13 return;
16 $author = id(new PhabricatorPeopleQuery())
17 ->setViewer($viewer)
18 ->withPHIDs(array($import->getAuthorPHID()))
19 ->needUserSettings(true)
20 ->executeOne();
22 $import_engine = $import->getEngine();
24 $data = $this->getTaskData();
25 $import->newLogMessage(
26 PhabricatorCalendarImportTriggerLogType::LOGTYPE,
27 array(
28 'via' => idx($data, 'via', self::VIA_TRIGGER),
29 ));
31 $import_engine->importEventsFromSource($author, $import, false);
34 private function loadImport() {
35 $viewer = PhabricatorUser::getOmnipotentUser();
37 $data = $this->getTaskData();
38 $import_phid = idx($data, 'importPHID');
40 $import = id(new PhabricatorCalendarImportQuery())
41 ->setViewer($viewer)
42 ->withPHIDs(array($import_phid))
43 ->executeOne();
44 if (!$import) {
45 throw new PhabricatorWorkerPermanentFailureException(
46 pht(
47 'Failed to load import with PHID "%s".',
48 $import_phid));
51 return $import;