vendor/shopware/storefront/Controller/SitemapController.php line 33

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Storefront\Controller;
  3. use Shopware\Core\Framework\Routing\Annotation\RouteScope;
  4. use Shopware\Core\Framework\Routing\Annotation\Since;
  5. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  6. use Shopware\Storefront\Page\Sitemap\SitemapPageLoadedHook;
  7. use Shopware\Storefront\Page\Sitemap\SitemapPageLoader;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. /**
  12.  * @Route(defaults={"_routeScope"={"storefront"}})
  13.  */
  14. class SitemapController extends StorefrontController
  15. {
  16.     /**
  17.      * @var SitemapPageLoader
  18.      */
  19.     private $sitemapPageLoader;
  20.     public function __construct(SitemapPageLoader $sitemapPageLoader)
  21.     {
  22.         $this->sitemapPageLoader $sitemapPageLoader;
  23.     }
  24.     /**
  25.      * @Since("6.0.0.0")
  26.      * @Route("/sitemap.xml", name="frontend.sitemap.xml", methods={"GET"}, defaults={"_format"="xml"})
  27.      */
  28.     public function sitemapXml(SalesChannelContext $contextRequest $request): Response
  29.     {
  30.         $page $this->sitemapPageLoader->load($request$context);
  31.         $this->hook(new SitemapPageLoadedHook($page$context));
  32.         $response $this->renderStorefront('@Storefront/storefront/page/sitemap/sitemap.xml.twig', ['page' => $page]);
  33.         $response->headers->set('content-type''text/xml; charset=utf-8');
  34.         return $response;
  35.     }
  36. }