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

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