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

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.  * @deprecated tag:v6.5.0 - reason:becomes-internal - Will be internal
  15.  */
  16. class SitemapController extends StorefrontController
  17. {
  18.     /**
  19.      * @var SitemapPageLoader
  20.      */
  21.     private $sitemapPageLoader;
  22.     /**
  23.      * @internal
  24.      */
  25.     public function __construct(SitemapPageLoader $sitemapPageLoader)
  26.     {
  27.         $this->sitemapPageLoader $sitemapPageLoader;
  28.     }
  29.     /**
  30.      * @Since("6.0.0.0")
  31.      * @Route("/sitemap.xml", name="frontend.sitemap.xml", methods={"GET"}, defaults={"_format"="xml"})
  32.      */
  33.     public function sitemapXml(SalesChannelContext $contextRequest $request): Response
  34.     {
  35.         $page $this->sitemapPageLoader->load($request$context);
  36.         $this->hook(new SitemapPageLoadedHook($page$context));
  37.         $response $this->renderStorefront('@Storefront/storefront/page/sitemap/sitemap.xml.twig', ['page' => $page]);
  38.         $response->headers->set('content-type''text/xml; charset=utf-8');
  39.         return $response;
  40.     }
  41. }