Bundle/PageBundle/Controller/BasePageController.php
protected function newPostAction(Request $request)
    {
        $entityManager = $this->get('doctrine.orm.entity_manager');
        $page = $this->getNewPage();

        $form = $this->get('form.factory')->create($this->getNewPageType(), $page);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $page = $this->get('victoire_page.page_helper')->setPosition($page);
            $page->setAuthor($this->getUser());
            $entityManager->persist($page);
            $entityManager->flush();

            // If the $page is a BusinessEntity (eg. an Article), compute it's url
            if (null !== $this->get('victoire_core.helper.business_entity_helper')->findByEntityInstance($page)) {
                $page = $this
                    ->get('victoire_business_page.business_page_builder')
                    ->generateEntityPageFromTemplate($page->getTemplate(), $page, $entityManager);
            }

            $this->congrat($this->get('translator')->trans('victoire_page.create.success', [], 'victoire'));

            return $this->getViewReferenceRedirect($request, $page);
        }

        return [
            'success' => false,
            'message' => $this->get('victoire_form.error_helper')->getRecursiveReadableErrors($form),
            'html'    => $this->get('templating')->render(
                $this->getBaseTemplatePath().':new.html.twig',
                ['form' => $form->createView()]
            ),
        ];
    }
protected function newPostAction(Request $request)
    {
        $entityManager = $this->get('doctrine.orm.entity_manager');
        $page = $this->getNewPage();

        $form = $this->get('form.factory')->create($this->getNewPageType(), $page);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $page = $this->get('victoire_page.page_helper')->setPosition($page);
            $page->setAuthor($this->getUser());
            $entityManager->persist($page);
            $entityManager->flush();

            // If the $page is a BusinessEntity (eg. an Article), compute it's url
            if (null !== $this->get('victoire_core.helper.business_entity_helper')->findByEntityInstance($page)) {
                $page = $this
                    ->get('victoire_business_page.business_page_builder')
                    ->generateEntityPageFromTemplate($page->getTemplate(), $page, $entityManager);
            }

            $this->congrat($this->get('translator')->trans('victoire_page.create.success', [], 'victoire'));

            return $this->getViewReferenceRedirect($request, $page);
        }

        return [
            'success' => false,
            'message' => $this->get('victoire_form.error_helper')->getRecursiveReadableErrors($form),
            'html'    => $this->get('templating')->render(
                $this->getBaseTemplatePath().':new.html.twig',
                ['form' => $form->createView()]
            ),
        ];
    }
protected function newPostAction ( Request $ request ) { $ entityManager = $ this -> get ( 'doctrine.orm.entity_manager' ) ; $ page = $ this -> getNewPage ( ) ; $ form = $ this -> get ( 'form.factory' ) -> create ( $ this -> getNewPageType ( ) , $ page ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ page = $ this -> get ( 'victoire_page.page_helper' ) -> setPosition ( $ page ) ; $ page -> setAuthor ( $ this -> getUser ( ) ) ; $ entityManager -> persist ( $ page ) ; $ entityManager -> flush ( ) ; // If the $page is a BusinessEntity (eg. an Article), compute it's url if ( null !== $ this -> get ( 'victoire_core.helper.business_entity_helper' ) -> findByEntityInstance ( $ page ) ) { $ page = $ this -> get ( 'victoire_business_page.business_page_builder' ) -> generateEntityPageFromTemplate ( $ page -> getTemplate ( ) , $ page , $ entityManager ) ; } $ this -> congrat ( $ this -> get ( 'translator' ) -> trans ( 'victoire_page.create.success' , [ ] , 'victoire' ) ) ; return $ this -> getViewReferenceRedirect ( $ request , $ page ) ; } return [ 'success' => false , 'message' => $ this -> get ( 'victoire_form.error_helper' ) -> getRecursiveReadableErrors ( $ form ) , 'html' => $ this -> get ( 'templating' ) -> render ( $ this -> getBaseTemplatePath ( ) . ':new.html.twig' , [ 'form' => $ form -> createView ( ) ] ) , ] ; }
Create a new Blog or Page.
Route is defined in inherited controllers.

@param Request $request

@return array|Response
Create a new Blog or Page . Route is defined in inherited controllers .