src/PN/Bundle/CMSBundle/Controller/Administration/BannerController.php
/**
     * Creates a new banner entity.
     *
     * @Route("/new", name="banner_new", methods={"GET", "POST"})
     */
Creates a new banner entity.
Creates a new banner entity .
public function newAction(Request $request) {
        $banner = new Banner();
        $form = $this->createForm(BannerType::class, $banner);
        $form->handleRequest($request);
        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $userName = $this->get('user')->getUserName();
            $banner->setCreator($userName);
            $banner->setModifiedBy($userName);
            $em->persist($banner);
            $em->flush();
            $uploadImage = $this->uploadImage($request, $form, $banner);
            if ($uploadImage != false) {
                $this->addFlash('success', 'Successfully saved');
                return $this->redirectToRoute('banner_index');
            }
            return $this->redirectToRoute('banner_edit', ["id" => $banner->getId()]);
        }
        return $this->render('cms/admin/banner/new.html.twig', array(
            'banner' => $banner,
            'form' => $form->createView(),
        ));
    }
public function newAction ( Request $ request ) { $ banner = new Banner ( ) ; $ form = $ this -> createForm ( BannerType :: class , $ banner ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isSubmitted ( ) && $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ userName = $ this -> get ( 'user' ) -> getUserName ( ) ; $ banner -> setCreator ( $ userName ) ; $ banner -> setModifiedBy ( $ userName ) ; $ em -> persist ( $ banner ) ; $ em -> flush ( ) ; $ uploadImage = $ this -> uploadImage ( $ request , $ form , $ banner ) ; if ( $ uploadImage != false ) { $ this -> addFlash ( 'success' , 'Successfully saved' ) ; return $ this -> redirectToRoute ( 'banner_index' ) ; } return $ this -> redirectToRoute ( 'banner_edit' , [ " id " => $ banner -> getId ( ) ] ) ; } return $ this -> render ( 'cms/admin/banner/new.html.twig' , array ( 'banner' => $ banner , 'form' => $ form -> createView ( ) , ) ) ; }
Creates a new banner entity.
Creates a new banner entity .