src/FormationBundle/Controller/FormationController.php
/**
     * Creates a new formation entity.
     *
     */
Creates a new formation entity.
Creates a new formation entity .
public function newAction(Request $request)
    {
        $user=$this->getUser();
        $formation = new Formation();
        $form = $this->createForm('FormationBundle\Form\FormationType', $formation);
        $form->handleRequest($request);
        if( $this->container->get( 'security.authorization_checker' )->isGranted( 'IS_AUTHENTICATED_FULLY' ) )
        {
            $formation->setCreator($user);
        }
        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($formation);
            $em->flush($formation);
            return $this->redirectToRoute('formation_show', array('id' => $formation->getId()));
        }
        return $this->render('formation/new.html.twig', array(
            'formation' => $formation,
            'form' => $form->createView(),
        ));
    }
public function newAction ( Request $ request ) { $ user = $ this -> getUser ( ) ; $ formation = new Formation ( ) ; $ form = $ this -> createForm ( 'FormationBundle\Form\FormationType' , $ formation ) ; $ form -> handleRequest ( $ request ) ; if ( $ this -> container -> get ( 'security.authorization_checker' ) -> isGranted ( 'IS_AUTHENTICATED_FULLY' ) ) { $ formation -> setCreator ( $ user ) ; } if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ formation ) ; $ em -> flush ( $ formation ) ; return $ this -> redirectToRoute ( 'formation_show' , array ( 'id' => $ formation -> getId ( ) ) ) ; } return $ this -> render ( 'formation/new.html.twig' , array ( 'formation' => $ formation , 'form' => $ form -> createView ( ) , ) ) ; }
Creates a new formation entity.
Creates a new formation entity .