public function getwinnersAction() { $quizset = $this->admin->getSubject(); if (!$quizset) { throw new NotFoundHttpException(sprintf('unable to find the object with id : %s')); } $em = $this->getDoctrine()->getManager(); try { $parsedData = Quiz::getQuizAnwsers(new QuizData($em), $quizset); return $this->render('AppBundle:begin:answer.html.twig', array('answers' => $parsedData)); } catch (InvalidArgumentException $e) { $this->addFlash('sonata_flash_error', 'Nie ma danych'); return new RedirectResponse($this->admin->generateUrl('list')); } }