getContainer()->getPermissionsService()->currentUserCanDelete(Entities::EVENTS)) { throw new AccessDeniedException('You are not allowed to delete event'); } $result = new CommandResult(); $this->checkMandatoryFields($command); /** @var EventApplicationService $eventApplicationService */ $eventApplicationService = $this->container->get('application.booking.event.service'); /** @var EventRepository $eventRepository */ $eventRepository = $this->container->get('domain.booking.event.repository'); /** @var Event $event */ $event = $eventRepository->getById($command->getArg('id')); if (!$event instanceof Event) { $result->setResult(CommandResult::RESULT_ERROR); $result->setMessage('Could not delete event'); return $result; } $eventRepository->beginTransaction(); try { $eventApplicationService->delete($event, $command->getField('applyGlobally')); } catch (QueryExecutionException $e) { $eventRepository->rollback(); throw $e; } $eventRepository->commit(); $result->setResult(CommandResult::RESULT_SUCCESS); $result->setMessage('Successfully deleted event'); return $result; } }