security->getUser(); if (!$user instanceof User) { throw new AccessDeniedHttpException('not a regular user'); } if (null === $invite = $calendar->getInviteForUser($user)) { throw new AccessDeniedHttpException('not invited to this calendar'); } if (!$this->security->isGranted(InviteVoter::ANSWER, $invite)) { throw new AccessDeniedHttpException('not allowed to answer on this invitation'); } if (!\in_array($answer, Invite::STATUSES, true)) { throw new BadRequestHttpException('answer not valid'); } $invite->setStatus($answer); $this->entityManager->flush(); $this->messageBus->dispatch(new InviteUpdateMessage($invite, $this->security->getUser())); return new JsonResponse(null, Response::HTTP_ACCEPTED, [], false); } }