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