vendor/crehler/advanced-menu/src/Controller/Storefront/ProductNavigationController.php line 46

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. /**
  3.  * @copyright 2020 Crehler Sp. z o. o.
  4.  * @link https://crehler.com/
  5.  * @support support@crehler.com
  6.  *
  7.  * @author Mateusz FlasiƄski
  8.  *
  9.  * For the full copyright and license information, please view the LICENSE
  10.  * file that was distributed with this source code.
  11.  */
  12. namespace Crehler\AdvancedMenu\Controller\Storefront;
  13. use Crehler\AdvancedMenu\Service\ProductsNavigationLoader;
  14. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  15. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  16. use Symfony\Component\Routing\Annotation\Route;
  17. /**
  18.  * @Route(defaults={"_routeScope"={"store-api"}})
  19.  */
  20. class ProductNavigationController extends AbstractController
  21. {
  22.     protected ProductsNavigationLoader $navigationLoader;
  23.     /***** ***
  24.      * ProductNavigationController constructor.
  25.      * @param ProductsNavigationLoader $navigationLoader
  26.      */
  27.     public function __construct(ProductsNavigationLoader $navigationLoader)
  28.     {
  29.         $this->navigationLoader $navigationLoader;
  30.     }
  31.     /**
  32.      * @Route("/store-api/mojebambino/productTree", name="frontend.mojebambino.productTree", options={"seo"="false"}, methods={"GET"}, defaults={"XmlHttpRequest": true})
  33.      */
  34.     public function productTree(SalesChannelContext $context)
  35.     {
  36.         $tree $this->navigationLoader->loadNavigationTree($context);
  37.         if (empty($tree)) {
  38.             return $this->json([]);
  39.         }
  40.         return $this->json($tree->jsonSerialize());
  41.     }
  42. }