src/Controller/XmlController.php
public function sitemapAction(Request $request, $locale)
    {
        $params = [];
        $params['domain'] = $this->getDomainName($request);
        $params['languages'] = $this->container->getParameter('networking_init_cms.page.languages');

        if ($locale != '' or count($params['languages']) == 1) {
            //sitemap ausgeben
            if ($locale == '') {  //use locale as default value
                $locale = $params['languages']['locale'];
            }
            $page_filter = ['visibility' => 'public', 'status' => 'status_published', 'locale' => $locale];
            $em = $this->getDoctrine()->getManager();
            $pageClass = $this->getParameter('networking_init_cms.manager.page.class');
            $params['pages'] = $em->getRepository($pageClass)->findBy($page_filter);
            $params['additional_links'] = $this->getAdditionalLinks($locale);
            //render xml
            $response = $this->render(
                'NetworkingInitCmsBundle:Sitemap:sitemap.xml.twig',
                $params
            );
        } else {
            //multilanguage site, return language overview sitemap

            /* TODO , check if / how "last modified" is possible */
            $response = $this->render(
                'NetworkingInitCmsBundle:Sitemap:multilingual_sitemap.xml.twig',
                $params
            );
        }

        $response->headers->set('Content-Type', 'application/xml');

        return $response;
    }
public function sitemapAction(Request $request, $locale)
    {
        $params = [];
        $params['domain'] = $this->getDomainName($request);
        $params['languages'] = $this->container->getParameter('networking_init_cms.page.languages');

        if ($locale != '' or count($params['languages']) == 1) {
            //sitemap ausgeben
            if ($locale == '') {  //use locale as default value
                $locale = $params['languages']['locale'];
            }
            $page_filter = ['visibility' => 'public', 'status' => 'status_published', 'locale' => $locale];
            $em = $this->getDoctrine()->getManager();
            $pageClass = $this->getParameter('networking_init_cms.manager.page.class');
            $params['pages'] = $em->getRepository($pageClass)->findBy($page_filter);
            $params['additional_links'] = $this->getAdditionalLinks($locale);
            //render xml
            $response = $this->render(
                'NetworkingInitCmsBundle:Sitemap:sitemap.xml.twig',
                $params
            );
        } else {
            //multilanguage site, return language overview sitemap

            /* TODO , check if / how "last modified" is possible */
            $response = $this->render(
                'NetworkingInitCmsBundle:Sitemap:multilingual_sitemap.xml.twig',
                $params
            );
        }

        $response->headers->set('Content-Type', 'application/xml');

        return $response;
    }
public function sitemapAction ( Request $ request , $ locale ) { $ params = [ ] ; $ params [ 'domain' ] = $ this -> getDomainName ( $ request ) ; $ params [ 'languages' ] = $ this -> container -> getParameter ( 'networking_init_cms.page.languages' ) ; if ( $ locale != '' or count ( $ params [ 'languages' ] ) == 1 ) { //sitemap ausgeben if ( $ locale == '' ) { //use locale as default value $ locale = $ params [ 'languages' ] [ 'locale' ] ; } $ page_filter = [ 'visibility' => 'public' , 'status' => 'status_published' , 'locale' => $ locale ] ; $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ pageClass = $ this -> getParameter ( 'networking_init_cms.manager.page.class' ) ; $ params [ 'pages' ] = $ em -> getRepository ( $ pageClass ) -> findBy ( $ page_filter ) ; $ params [ 'additional_links' ] = $ this -> getAdditionalLinks ( $ locale ) ; //render xml $ response = $ this -> render ( 'NetworkingInitCmsBundle:Sitemap:sitemap.xml.twig' , $ params ) ; } else { //multilanguage site, return language overview sitemap /* TODO , check if / how "last modified" is possible */ $ response = $ this -> render ( 'NetworkingInitCmsBundle:Sitemap:multilingual_sitemap.xml.twig' , $ params ) ; } $ response -> headers -> set ( 'Content-Type' , 'application/xml' ) ; return $ response ; }
Render the xml Sitemap.

@param Request $request

@return Response
Render the xml Sitemap .