vendor/kunstmaan/sitemap-bundle/Controller/SitemapController.php line 59

Open in your IDE?
  1. <?php
  2. namespace Kunstmaan\SitemapBundle\Controller;
  3. use Kunstmaan\SitemapBundle\Event\PreSitemapRenderEvent;
  4. use Symfony\Component\Routing\Annotation\Route;
  5. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
  6. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  7. use Symfony\Component\HttpFoundation\Request;
  8. class SitemapController extends Controller
  9. {
  10.     /**
  11.      * This will generate a sitemap for the specified locale.
  12.      * Use the mode parameter to select in which mode the sitemap should be
  13.      * generated. At this moment only XML is supported
  14.      *
  15.      * @Route("/sitemap-{locale}.{_format}", name="KunstmaanSitemapBundle_sitemap",
  16.      *                                       requirements={"_format" = "xml"})
  17.      * @Template("@KunstmaanSitemap/Sitemap/view.xml.twig")
  18.      *
  19.      * @param $locale
  20.      *
  21.      * @return array
  22.      */
  23.     public function sitemapAction($locale)
  24.     {
  25.         $nodeMenu $this->get('kunstmaan_node.node_menu');
  26.         $nodeMenu->setLocale($locale);
  27.         $nodeMenu->setIncludeOffline(false);
  28.         $nodeMenu->setIncludeHiddenFromNav(true);
  29.         $nodeMenu->setCurrentNode(null);
  30.         $event = new PreSitemapRenderEvent($locale);
  31.         $this->get('event_dispatcher')->dispatch(PreSitemapRenderEvent::NAME$event);
  32.         return array(
  33.             'nodemenu' => $nodeMenu,
  34.             'locale' => $locale,
  35.             'extraItems' => $event->getExtraItems(),
  36.         );
  37.     }
  38.     /**
  39.      * This will generate a sitemap index file to define a sub sitemap for each
  40.      * language. Info at:
  41.      * https://support.google.com/webmasters/answer/75712?rd=1 Use the mode
  42.      * parameter to select in which mode the sitemap should be generated. At
  43.      * this moment only XML is supported
  44.      *
  45.      * @Route("/sitemap.{_format}", name="KunstmaanSitemapBundle_sitemapindex",
  46.      *                              requirements={"_format" = "xml"})
  47.      * @Template("@KunstmaanSitemap/SitemapIndex/view.xml.twig")
  48.      *
  49.      * @param Request $request
  50.      *
  51.      * @return array
  52.      */
  53.     public function sitemapIndexAction(Request $request)
  54.     {
  55.         $locales $this->get('kunstmaan_admin.domain_configuration')
  56.             ->getBackendLocales();
  57.         return array(
  58.             'locales' => $locales,
  59.             'host' => $request->getSchemeAndHttpHost(),
  60.         );
  61.     }
  62. }