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

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\SitemapPageLoader;
  7. use Symfony\Component\HttpFoundation\Request;
  8. use Symfony\Component\HttpFoundation\Response;
  9. use Symfony\Component\Routing\Annotation\Route;
  10. /**
  11.  * @RouteScope(scopes={"storefront"})
  12.  */
  13. class SitemapController extends StorefrontController
  14. {
  15.     /**
  16.      * @var SitemapPageLoader
  17.      */
  18.     private $sitemapPageLoader;
  19.     public function __construct(SitemapPageLoader $sitemapPageLoader)
  20.     {
  21.         $this->sitemapPageLoader $sitemapPageLoader;
  22.     }
  23.     /**
  24.      * @Since("6.0.0.0")
  25.      * @Route("/sitemap.xml", name="frontend.sitemap.xml", methods={"GET"}, defaults={"_format"="xml"})
  26.      */
  27.     public function sitemapXml(SalesChannelContext $contextRequest $request): Response
  28.     {
  29.         $page $this->sitemapPageLoader->load($request$context);
  30.         $response $this->renderStorefront('@Storefront/storefront/page/sitemap/sitemap.xml.twig', ['page' => $page]);
  31.         $response->headers->set('content-type''text/xml; charset=utf-8');
  32.         return $response;
  33.     }
  34. }