/**
  * @Template
  *
  * @param Request $request
  * @param Question $question
  * @param string $answer
  * @return array
  */
 public function detailAction(Request $request, Question $question, $answer = null)
 {
     /** @var User $currentUser */
     $currentUser = $this->entityManager->merge($this->loginUser->getUser());
     if ($answer) {
         $correct = $answer == $question->getCorrectAnswer();
         $consumption = new QuestionAnswer($currentUser, $question, $correct);
         $this->entityManager->persist($consumption);
         $this->entityManager->flush();
         return new RedirectResponse($this->urlGenerator->generate('home'));
     }
     return ['question' => $question];
 }
 /**
  * @Template
  *
  * @param Request $request
  * @return array
  */
 public function consumptionAction(Request $request)
 {
     /** @var User $currentUser */
     $currentUser = $this->entityManager->merge($this->loginUser->getUser());
     $users = $this->userRepository->findAllExceptUser($currentUser);
     $receiverId = $request->query->get('receiver_id');
     $receiver = $this->userRepository->findOneById($receiverId);
     if ($receiver) {
         $consumption = new Consumption($currentUser, $receiver);
         $this->entityManager->persist($consumption);
         $this->entityManager->flush();
         return new RedirectResponse($this->urlGenerator->generate('question_detail', ['id' => $this->questionRepository->findOneRandom()->getId()]));
     }
     return ['users' => $users];
 }