src/PN/Bundle/CMSBundle/Controller/Administration/FaqController.php
/**
     * Creates a new faq entity.
     *
     * @Route("/new", name="faq_new", methods={"GET", "POST"})
     */
Creates a new faq entity.
Creates a new faq entity .
public function newAction(Request $request) {
        $faq = new Faq();
        $form = $this->createForm(FaqType::class, $faq);
        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $userName = $this->get('user')->getUserName();
            $faq->setCreator($userName);
            $faq->setModifiedBy($userName);
            $em->persist($faq);
            $em->flush();
            $this->addFlash('success', 'Successfully saved');
            return $this->redirectToRoute('faq_index');
        }
        return $this->render('cms/admin/faq/new.html.twig', array(
                    'faq' => $faq,
                    'form' => $form->createView(),
        ));
    }
public function newAction ( Request $ request ) { $ faq = new Faq ( ) ; $ form = $ this -> createForm ( FaqType :: class , $ faq ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ userName = $ this -> get ( 'user' ) -> getUserName ( ) ; $ faq -> setCreator ( $ userName ) ; $ faq -> setModifiedBy ( $ userName ) ; $ em -> persist ( $ faq ) ; $ em -> flush ( ) ; $ this -> addFlash ( 'success' , 'Successfully saved' ) ; return $ this -> redirectToRoute ( 'faq_index' ) ; } return $ this -> render ( 'cms/admin/faq/new.html.twig' , array ( 'faq' => $ faq , 'form' => $ form -> createView ( ) , ) ) ; }
Creates a new faq entity.
Creates a new faq entity .