getViewer(); $id = $request->getURIData('id'); $event = id(new PhabricatorCalendarEventQuery()) ->setViewer($viewer) ->withIDs(array($id)) ->executeOne(); if (!$event) { return new Aphront404Response(); } if ($event->isChildEvent()) { $target = $event->getParentEvent(); } else { $target = $event; } return $this->newICSResponse( $viewer, $target->getICSFileName(), array($target)); } }