src/Storefront/Controller/NavigationController.php line 34

  1. <?php declare(strict_types=1);
  2. namespace Shopware\Storefront\Controller;
  3. use Shopware\Core\Framework\Log\Package;
  4. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  5. use Shopware\Storefront\Page\Navigation\NavigationPageLoadedHook;
  6. use Shopware\Storefront\Page\Navigation\NavigationPageLoaderInterface;
  7. use Shopware\Storefront\Pagelet\Menu\Offcanvas\MenuOffcanvasPageletLoadedHook;
  8. use Shopware\Storefront\Pagelet\Menu\Offcanvas\MenuOffcanvasPageletLoaderInterface;
  9. use Symfony\Component\HttpFoundation\Request;
  10. use Symfony\Component\HttpFoundation\Response;
  11. use Symfony\Component\Routing\Annotation\Route;
  12. /**
  13.  * @internal
  14.  */
  15. #[Route(defaults: ['_routeScope' => ['storefront']])]
  16. #[Package('content')]
  17. class NavigationController extends StorefrontController
  18. {
  19.     /**
  20.      * @internal
  21.      */
  22.     public function __construct(private readonly NavigationPageLoaderInterface $navigationPageLoader, private readonly MenuOffcanvasPageletLoaderInterface $offcanvasLoader)
  23.     {
  24.     }
  25.     #[Route(path'/'name'frontend.home.page'options: ['seo' => true], defaults: ['_httpCache' => true], methods: ['GET'])]
  26.     public function home(Request $requestSalesChannelContext $context): ?Response
  27.     {
  28.         $page $this->navigationPageLoader->load($request$context);
  29.         $this->hook(new NavigationPageLoadedHook($page$context));
  30.         return $this->renderStorefront('@Storefront/storefront/page/content/index.html.twig', ['page' => $page]);
  31.     }
  32.     #[Route(path'/navigation/{navigationId}'name'frontend.navigation.page'options: ['seo' => true], defaults: ['_httpCache' => true], methods: ['GET'])]
  33.     public function index(SalesChannelContext $contextRequest $request): 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.     #[Route(path'/widgets/menu/offcanvas'name'frontend.menu.offcanvas'defaults: ['XmlHttpRequest' => true'_httpCache' => true], methods: ['GET'])]
  40.     public function offcanvas(Request $requestSalesChannelContext $context): Response
  41.     {
  42.         $page $this->offcanvasLoader->load($request$context);
  43.         $this->hook(new MenuOffcanvasPageletLoadedHook($page$context));
  44.         $response $this->renderStorefront(
  45.             '@Storefront/storefront/layout/navigation/offcanvas/navigation-pagelet.html.twig',
  46.             ['page' => $page]
  47.         );
  48.         $response->headers->set('x-robots-tag''noindex');
  49.         return $response;
  50.     }
  51. }