<?php
namespace AppBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Component\HttpFoundation\Request;
class RoutingController extends Controller
{
/**
* @Route("/sitemap.xml")
* @Method("GET")
*/
public function sitemapAction(Request $request)
{
$em = $this->getDoctrine()->getEntityActionManager();
$urls = array();
$hostname = $request->getHost();
foreach ($em->getRepository('AppBundle:Page')->findAll() as $page) {
$urls[] = array('loc' => $this->get('router')->generate('admin_page_show',
array('id' => $page->getId())), 'priority' => '0.5');
}
return $this->render('default/sitemap.xml.twig', array(
'urls' => $urls,
'hostname' => $hostname
));
}
}