src/AppBundle/Controller/RoutingController.php line 18

Open in your IDE?
  1. <?php
  2. namespace AppBundle\Controller;
  3. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  4. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
  5. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
  6. use Symfony\Component\HttpFoundation\Request;
  7. class RoutingController extends Controller
  8. {
  9.     /**
  10.      * @Route("/sitemap.xml")
  11.      * @Method("GET")
  12.      */
  13.     public function sitemapAction(Request $request
  14.     {
  15.         $em $this->getDoctrine()->getEntityActionManager();
  16.         
  17.         $urls = array();
  18.         $hostname $request->getHost();
  19.         
  20.         foreach ($em->getRepository('AppBundle:Page')->findAll() as $page) {
  21.             $urls[] = array('loc' => $this->get('router')->generate('admin_page_show'
  22.                     array('id' => $page->getId())), 'priority' => '0.5');
  23.         }
  24.         return $this->render('default/sitemap.xml.twig', array(
  25.             'urls' => $urls
  26.             'hostname' => $hostname
  27.         ));
  28.     }
  29. }