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

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