Exemplo n.º 1
0
 /**
  * Displays a form to create a new Quiz entity.
  *
  * @Route("/dodaj", name="quiz_new")
  * @Template()
  */
 public function newAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $qb = $em->getRepository('AppBundle:Quiz')->createQueryBuilder('q');
     $qb->select('COUNT(q)');
     $count = $qb->getQuery()->getSingleScalarResult();
     $entity = new Quiz();
     $entity->setTitle('Quiz - ' . $count);
     $form = $this->createCreateForm($entity);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $em = $this->getDoctrine()->getManager();
         $em->persist($entity);
         $em->flush();
         return $this->redirectToRoute('quiz_show', array('link' => $entity->getLink()));
     }
     return array('entity' => $entity, 'form' => $form->createView());
 }