vendor/shopware/storefront/Controller/NavigationController.php line 50

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\Framework\Cache\Annotation\HttpCache;
  7. use Shopware\Storefront\Page\Navigation\NavigationPageLoadedHook;
  8. use Shopware\Storefront\Page\Navigation\NavigationPageLoaderInterface;
  9. use Shopware\Storefront\Pagelet\Menu\Offcanvas\MenuOffcanvasPageletLoadedHook;
  10. use Shopware\Storefront\Pagelet\Menu\Offcanvas\MenuOffcanvasPageletLoaderInterface;
  11. use Symfony\Component\HttpFoundation\Request;
  12. use Symfony\Component\HttpFoundation\Response;
  13. use Symfony\Component\Routing\Annotation\Route;
  14. /**
  15.  * @Route(defaults={"_routeScope"={"storefront"}})
  16.  *
  17.  * @deprecated tag:v6.5.0 - reason:becomes-internal - Will be internal
  18.  */
  19. class NavigationController extends StorefrontController
  20. {
  21.     private NavigationPageLoaderInterface $navigationPageLoader;
  22.     private MenuOffcanvasPageletLoaderInterface $offcanvasLoader;
  23.     /**
  24.      * @internal
  25.      */
  26.     public function __construct(
  27.         NavigationPageLoaderInterface $navigationPageLoader,
  28.         MenuOffcanvasPageletLoaderInterface $offcanvasLoader
  29.     ) {
  30.         $this->navigationPageLoader $navigationPageLoader;
  31.         $this->offcanvasLoader $offcanvasLoader;
  32.     }
  33.     /**
  34.      * @Since("6.0.0.0")
  35.      * @HttpCache()
  36.      * @Route("/", name="frontend.home.page", options={"seo"="true"}, methods={"GET"})
  37.      */
  38.     public function home(Request $requestSalesChannelContext $context): ?Response
  39.     {
  40.         $page $this->navigationPageLoader->load($request$context);
  41.         $this->hook(new NavigationPageLoadedHook($page$context));
  42.         return $this->renderStorefront('@Storefront/storefront/page/content/index.html.twig', ['page' => $page]);
  43.     }
  44.     /**
  45.      * @Since("6.3.3.0")
  46.      * @HttpCache()
  47.      * @Route("/navigation/{navigationId}", name="frontend.navigation.page", options={"seo"=true}, methods={"GET"})
  48.      */
  49.     public function index(SalesChannelContext $contextRequest $request): Response
  50.     {
  51.         $page $this->navigationPageLoader->load($request$context);
  52.         $this->hook(new NavigationPageLoadedHook($page$context));
  53.         return $this->renderStorefront('@Storefront/storefront/page/content/index.html.twig', ['page' => $page]);
  54.     }
  55.     /**
  56.      * @Since("6.0.0.0")
  57.      * @HttpCache()
  58.      * @Route("/widgets/menu/offcanvas", name="frontend.menu.offcanvas", methods={"GET"}, defaults={"XmlHttpRequest"=true})
  59.      */
  60.     public function offcanvas(Request $requestSalesChannelContext $context): Response
  61.     {
  62.         $page $this->offcanvasLoader->load($request$context);
  63.         $this->hook(new MenuOffcanvasPageletLoadedHook($page$context));
  64.         $response $this->renderStorefront(
  65.             '@Storefront/storefront/layout/navigation/offcanvas/navigation-pagelet.html.twig',
  66.             ['page' => $page]
  67.         );
  68.         $response->headers->set('x-robots-tag''noindex');
  69.         return $response;
  70.     }
  71. }