Bundle/SitemapBundle/Controller/SitemapController.php
public function reorganizeAction(Request $request)
    {
        if ($request->isMethod('POST')) {
            $this->get('victoire_sitemap.sort.handler')->handle(
                $request->request->get('sorted')
            );
            $response['message'] = $this->get('translator')->trans('sitemap.changed.success', [], 'victoire');
        }

        $basePageRepo = $this->getDoctrine()->getManager()->getRepository('VictoirePageBundle:BasePage');
        $basePages = $basePageRepo
            ->getAll()
            ->joinSeo()
            ->joinSeoTranslations($request->getLocale())
            ->run();

        $forms = [];
        foreach ($basePages as $_page) {
            $_pageSeo = $_page->getSeo() ?: new PageSeo();
            $forms[$_page->getId()] = $this->createSitemapPriorityType($_page, $_pageSeo)->createView();
        }

        $response['success'] = true;
        $response['html'] = $this->container->get('templating')->render(
            'VictoireSitemapBundle:Sitemap:reorganize.html.twig',
            [
                'pages' => $basePageRepo->findByParent(null, ['position' => 'ASC']),
                'forms' => $forms,
            ]
        );

        return new JsonResponse($response);
    }
public function reorganizeAction(Request $request)
    {
        if ($request->isMethod('POST')) {
            $this->get('victoire_sitemap.sort.handler')->handle(
                $request->request->get('sorted')
            );
            $response['message'] = $this->get('translator')->trans('sitemap.changed.success', [], 'victoire');
        }

        $basePageRepo = $this->getDoctrine()->getManager()->getRepository('VictoirePageBundle:BasePage');
        $basePages = $basePageRepo
            ->getAll()
            ->joinSeo()
            ->joinSeoTranslations($request->getLocale())
            ->run();

        $forms = [];
        foreach ($basePages as $_page) {
            $_pageSeo = $_page->getSeo() ?: new PageSeo();
            $forms[$_page->getId()] = $this->createSitemapPriorityType($_page, $_pageSeo)->createView();
        }

        $response['success'] = true;
        $response['html'] = $this->container->get('templating')->render(
            'VictoireSitemapBundle:Sitemap:reorganize.html.twig',
            [
                'pages' => $basePageRepo->findByParent(null, ['position' => 'ASC']),
                'forms' => $forms,
            ]
        );

        return new JsonResponse($response);
    }
public function reorganizeAction ( Request $ request ) { if ( $ request -> isMethod ( 'POST' ) ) { $ this -> get ( 'victoire_sitemap.sort.handler' ) -> handle ( $ request -> request -> get ( 'sorted' ) ) ; $ response [ 'message' ] = $ this -> get ( 'translator' ) -> trans ( 'sitemap.changed.success' , [ ] , 'victoire' ) ; } $ basePageRepo = $ this -> getDoctrine ( ) -> getManager ( ) -> getRepository ( 'VictoirePageBundle:BasePage' ) ; $ basePages = $ basePageRepo -> getAll ( ) -> joinSeo ( ) -> joinSeoTranslations ( $ request -> getLocale ( ) ) -> run ( ) ; $ forms = [ ] ; foreach ( $ basePages as $ _page ) { $ _pageSeo = $ _page -> getSeo ( ) ? : new PageSeo ( ) ; $ forms [ $ _page -> getId ( ) ] = $ this -> createSitemapPriorityType ( $ _page , $ _pageSeo ) -> createView ( ) ; } $ response [ 'success' ] = true ; $ response [ 'html' ] = $ this -> container -> get ( 'templating' ) -> render ( 'VictoireSitemapBundle:Sitemap:reorganize.html.twig' , [ 'pages' => $ basePageRepo -> findByParent ( null , [ 'position' => 'ASC' ] ) , 'forms' => $ forms , ] ) ; return new JsonResponse ( $ response ) ; }
Show Sitemap as tree and save new order if necessary.

@Route("/reorganize", name="victoire_sitemap_reorganize", options={"expose"=true})

@return JsonResponse
Show Sitemap as tree and save new order if necessary .