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

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\System\SalesChannel\SalesChannelContext;
  5. use Shopware\Storefront\Framework\Cache\Annotation\HttpCache;
  6. use Shopware\Storefront\Page\Navigation\NavigationPageLoader;
  7. use Shopware\Storefront\Pagelet\Menu\Offcanvas\MenuOffcanvasPageletLoaderInterface;
  8. use Symfony\Component\HttpFoundation\Request;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\Routing\Annotation\Route;
  11. /**
  12.  * @RouteScope(scopes={"storefront"})
  13.  */
  14. class NavigationController extends StorefrontController
  15. {
  16.     /**
  17.      * @var NavigationPageLoader
  18.      */
  19.     private $navigationPageLoader;
  20.     /**
  21.      * @var MenuOffcanvasPageletLoaderInterface
  22.      */
  23.     private $offcanvasLoader;
  24.     public function __construct(
  25.         NavigationPageLoader $navigationPageLoader,
  26.         MenuOffcanvasPageletLoaderInterface $offcanvasLoader
  27.     ) {
  28.         $this->navigationPageLoader $navigationPageLoader;
  29.         $this->offcanvasLoader $offcanvasLoader;
  30.     }
  31.     /**
  32.      * @HttpCache()
  33.      * @Route("/", name="frontend.home.page", options={"seo"="true"}, methods={"GET"})
  34.      */
  35.     public function home(Request $requestSalesChannelContext $context): ?Response
  36.     {
  37.         $page $this->navigationPageLoader->load($request$context);
  38.         return $this->renderStorefront('@Storefront/storefront/page/content/index.html.twig', ['page' => $page]);
  39.     }
  40.     /**
  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.         return $this->renderStorefront('@Storefront/storefront/page/content/index.html.twig', ['page' => $page]);
  48.     }
  49.     /**
  50.      * @HttpCache()
  51.      * @Route("/widgets/menu/offcanvas", name="frontend.menu.offcanvas", methods={"GET"}, defaults={"XmlHttpRequest"=true})
  52.      */
  53.     public function offcanvas(Request $requestSalesChannelContext $context): Response
  54.     {
  55.         $page $this->offcanvasLoader->load($request$context);
  56.         return $this->renderStorefront(
  57.             '@Storefront/storefront/layout/navigation/offcanvas/navigation-pagelet.html.twig',
  58.             ['page' => $page]
  59.         );
  60.     }
  61. }