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

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