vendor/shopware/platform/src/Storefront/Controller/NavigationController.php line 39

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. class NavigationController extends StorefrontController
  18. {
  19.     private NavigationPageLoaderInterface $navigationPageLoader;
  20.     private MenuOffcanvasPageletLoaderInterface $offcanvasLoader;
  21.     public function __construct(
  22.         NavigationPageLoaderInterface $navigationPageLoader,
  23.         MenuOffcanvasPageletLoaderInterface $offcanvasLoader
  24.     ) {
  25.         $this->navigationPageLoader $navigationPageLoader;
  26.         $this->offcanvasLoader $offcanvasLoader;
  27.     }
  28.     /**
  29.      * @Since("6.0.0.0")
  30.      * @HttpCache()
  31.      * @Route("/", name="frontend.home.page", options={"seo"="true"}, methods={"GET"})
  32.      */
  33.     public function home(Request $requestSalesChannelContext $context): ?Response
  34.     {
  35.         $page $this->navigationPageLoader->load($request$context);
  36.         $this->hook(new NavigationPageLoadedHook($page$context));
  37.         return $this->renderStorefront('@Storefront/storefront/page/content/index.html.twig', ['page' => $page]);
  38.     }
  39.     /**
  40.      * @Since("6.3.3.0")
  41.      * @HttpCache()
  42.      * @Route("/navigation/{navigationId}", name="frontend.navigation.page", options={"seo"=true}, methods={"GET"})
  43.      */
  44.     public function index(SalesChannelContext $contextRequest $request): Response
  45.     {
  46.         $page $this->navigationPageLoader->load($request$context);
  47.         $this->hook(new NavigationPageLoadedHook($page$context));
  48.         return $this->renderStorefront('@Storefront/storefront/page/content/index.html.twig', ['page' => $page]);
  49.     }
  50.     /**
  51.      * @Since("6.0.0.0")
  52.      * @HttpCache()
  53.      * @Route("/widgets/menu/offcanvas", name="frontend.menu.offcanvas", methods={"GET"}, defaults={"XmlHttpRequest"=true})
  54.      */
  55.     public function offcanvas(Request $requestSalesChannelContext $context): Response
  56.     {
  57.         $page $this->offcanvasLoader->load($request$context);
  58.         $this->hook(new MenuOffcanvasPageletLoadedHook($page$context));
  59.         $response $this->renderStorefront(
  60.             '@Storefront/storefront/layout/navigation/offcanvas/navigation-pagelet.html.twig',
  61.             ['page' => $page]
  62.         );
  63.         $response->headers->set('x-robots-tag''noindex');
  64.         return $response;
  65.     }
  66. }