getContainer()->getPermissionsService()->currentUserCanWriteStatus(Entities::EVENT)) { throw new AccessDeniedException('You are not allowed to update event status'); } $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'); $requestedStatus = $command->getField('status'); /** @var Event $Event */ $event = $eventRepository->getById((int)$command->getArg('id')); $eventRepository->beginTransaction(); try { $updatedEvents = $eventApplicationService->updateStatus( $event, $requestedStatus, $command->getField('applyGlobally') ); } catch (QueryExecutionException $e) { $eventRepository->rollback(); throw $e; } $eventRepository->commit(); $result->setResult(CommandResult::RESULT_SUCCESS); $result->setMessage('Successfully updated event status'); $result->setData([ 'status' => $requestedStatus, 'message' => BackendStrings::getEventStrings()['event_status_changed'] . $requestedStatus, Entities::EVENTS => $updatedEvents->toArray(), ]); return $result; } }