Bundle/BlogBundle/Controller/BlogController.php
public function categoryAction(Request $request, BasePage $blog)
    {
        $entityManager = $this->getDoctrine()->getManager();
        $form = $this->createForm($this->getPageCategoryType(), $blog);
        $businessProperties = $this->getBusinessProperties($blog);

        $form->handleRequest($request);

        if ($form->isValid()) {
            $entityManager->persist($blog);
            $entityManager->flush();

            return new JsonResponse([
                'success' => true,
                'url'     => $this->generateUrl('victoire_core_page_show', ['_locale' => $blog->getCurrentLocale(), 'url' => $blog->getUrl()]), ]);
        }
        //we display the form
        $errors = $this->get('victoire_form.error_helper')->getRecursiveReadableErrors($form);
        if ($errors != '') {
            return new JsonResponse(
                [
                    'html' => $this->container->get('templating')->render(
                        'VictoireBlogBundle:Blog:Tabs/_category.html.twig',
                        [
                            'blog'               => $blog,
                            'form'               => $form->createView(),
                            'businessProperties' => $businessProperties,
                        ]
                    ),
                    'message' => $errors,
                ]
            );
        }

        return new Response(
            $this->container->get('templating')->render(
                    $this->getBaseTemplatePath().':Tabs/_category.html.twig',
                    [
                        'blog'               => $blog,
                        'form'               => $form->createView(),
                        'businessProperties' => $businessProperties,
                    ]
                )
        );
    }
public function categoryAction(Request $request, BasePage $blog)
    {
        $entityManager = $this->getDoctrine()->getManager();
        $form = $this->createForm($this->getPageCategoryType(), $blog);
        $businessProperties = $this->getBusinessProperties($blog);

        $form->handleRequest($request);

        if ($form->isValid()) {
            $entityManager->persist($blog);
            $entityManager->flush();

            return new JsonResponse([
                'success' => true,
                'url'     => $this->generateUrl('victoire_core_page_show', ['_locale' => $blog->getCurrentLocale(), 'url' => $blog->getUrl()]), ]);
        }
        //we display the form
        $errors = $this->get('victoire_form.error_helper')->getRecursiveReadableErrors($form);
        if ($errors != '') {
            return new JsonResponse(
                [
                    'html' => $this->container->get('templating')->render(
                        'VictoireBlogBundle:Blog:Tabs/_category.html.twig',
                        [
                            'blog'               => $blog,
                            'form'               => $form->createView(),
                            'businessProperties' => $businessProperties,
                        ]
                    ),
                    'message' => $errors,
                ]
            );
        }

        return new Response(
            $this->container->get('templating')->render(
                    $this->getBaseTemplatePath().':Tabs/_category.html.twig',
                    [
                        'blog'               => $blog,
                        'form'               => $form->createView(),
                        'businessProperties' => $businessProperties,
                    ]
                )
        );
    }
public function categoryAction ( Request $ request , BasePage $ blog ) { $ entityManager = $ this -> getDoctrine ( ) -> getManager ( ) ; $ form = $ this -> createForm ( $ this -> getPageCategoryType ( ) , $ blog ) ; $ businessProperties = $ this -> getBusinessProperties ( $ blog ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ entityManager -> persist ( $ blog ) ; $ entityManager -> flush ( ) ; return new JsonResponse ( [ 'success' => true , 'url' => $ this -> generateUrl ( 'victoire_core_page_show' , [ '_locale' => $ blog -> getCurrentLocale ( ) , 'url' => $ blog -> getUrl ( ) ] ) , ] ) ; } //we display the form $ errors = $ this -> get ( 'victoire_form.error_helper' ) -> getRecursiveReadableErrors ( $ form ) ; if ( $ errors != '' ) { return new JsonResponse ( [ 'html' => $ this -> container -> get ( 'templating' ) -> render ( 'VictoireBlogBundle:Blog:Tabs/_category.html.twig' , [ 'blog' => $ blog , 'form' => $ form -> createView ( ) , 'businessProperties' => $ businessProperties , ] ) , 'message' => $ errors , ] ) ; } return new Response ( $ this -> container -> get ( 'templating' ) -> render ( $ this -> getBaseTemplatePath ( ) . ':Tabs/_category.html.twig' , [ 'blog' => $ blog , 'form' => $ form -> createView ( ) , 'businessProperties' => $ businessProperties , ] ) ) ; }
List Blog Categories.

@param Request  $request
@param BasePage $blog

@Route("/{id}/category", name="victoire_blog_category")
@ParamConverter("blog", class="VictoirePageBundle:BasePage")

@return Response
List Blog Categories .