src/AppBundle/Controller/EventoController.php
/**
     * Creates a new evento entity.
     *
     * @Route("/nuevo", name="evento_new")
     * @Method({"GET", "POST"})
     */
Creates a new evento entity.
Creates a new evento entity .
public function newAction(Request $request)
    {
        $evento = new Evento();
        $this->denyAccessUnlessGranted('AGENDA_CREATE',$evento);
        $form = $this->createForm('AppBundle\Form\EventoType', $evento);
        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $evento->setUsuario($this->getUser());
            $em->persist($evento);
            $em->flush();
            return $this->redirectToRoute('evento_show', [
                'id' => $evento->getId()
            ]);
        }
        return $this->render('evento/new.html.twig', [
            'evento' => $evento,
            'form' => $form->createView()
        ]);
    }
public function newAction ( Request $ request ) { $ evento = new Evento ( ) ; $ this -> denyAccessUnlessGranted ( 'AGENDA_CREATE' , $ evento ) ; $ form = $ this -> createForm ( 'AppBundle\Form\EventoType' , $ evento ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ evento -> setUsuario ( $ this -> getUser ( ) ) ; $ em -> persist ( $ evento ) ; $ em -> flush ( ) ; return $ this -> redirectToRoute ( 'evento_show' , [ 'id' => $ evento -> getId ( ) ] ) ; } return $ this -> render ( 'evento/new.html.twig' , [ 'evento' => $ evento , 'form' => $ form -> createView ( ) ] ) ; }
Creates a new evento entity.
Creates a new evento entity .