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()) {
16 $author = id(new PhabricatorPeopleQuery())
18 ->withPHIDs(array($import->getAuthorPHID()))
19 ->needUserSettings(true)
22 $import_engine = $import->getEngine();
24 $data = $this->getTaskData();
25 $import->newLogMessage(
26 PhabricatorCalendarImportTriggerLogType
::LOGTYPE
,
28 'via' => idx($data, 'via', self
::VIA_TRIGGER
),
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())
42 ->withPHIDs(array($import_phid))
45 throw new PhabricatorWorkerPermanentFailureException(
47 'Failed to load import with PHID "%s".',