src/AppBundle/Controller/ProjectController.php
/**
     * Creates a new project entity.
     *
     * @Route("/new", name="project_new")
     * @Method({"GET", "POST"})
     */
Creates a new project entity.
Creates a new project entity .
public function newAction(Request $request)
    {
        $user = $this->getUser();
        $project = new Project();
        $form = $this->createForm('AppBundle\Form\ProjectType', $project);
        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            $project->setManager($user);
            $project->setCreatedAt(new \DateTime('now'));
            $em = $this->getDoctrine()->getManager();
            $em->persist($project);
            $em->flush();
            return $this->redirectToRoute('project_index', array('id' => $project->getId()));
        }
        return $this->render(':project:new.html.twig', array(
            'project' => $project,
            'form' => $form->createView(),
        ));
    }
public function newAction ( Request $ request ) { $ user = $ this -> getUser ( ) ; $ project = new Project ( ) ; $ form = $ this -> createForm ( 'AppBundle\Form\ProjectType' , $ project ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ project -> setManager ( $ user ) ; $ project -> setCreatedAt ( new \ DateTime ( 'now' ) ) ; $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ project ) ; $ em -> flush ( ) ; return $ this -> redirectToRoute ( 'project_index' , array ( 'id' => $ project -> getId ( ) ) ) ; } return $ this -> render ( ':project:new.html.twig' , array ( 'project' => $ project , 'form' => $ form -> createView ( ) , ) ) ; }
Creates a new project entity.
Creates a new project entity .