vendor/shopware/storefront/Pagelet/Menu/Offcanvas/MenuOffcanvasPageletLoader.php line 47

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Storefront\Pagelet\Menu\Offcanvas;
  3. use Shopware\Core\Content\Category\Exception\CategoryNotFoundException;
  4. use Shopware\Core\Content\Category\Service\NavigationLoaderInterface;
  5. use Shopware\Core\Framework\DataAbstractionLayer\Exception\InconsistentCriteriaIdsException;
  6. use Shopware\Core\Framework\Routing\Exception\MissingRequestParameterException;
  7. use Shopware\Core\System\Annotation\Concept\ExtensionPattern\Decoratable;
  8. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  9. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  10. use Symfony\Component\HttpFoundation\Request;
  11. /**
  12.  * @Decoratable()
  13.  */
  14. class MenuOffcanvasPageletLoader implements MenuOffcanvasPageletLoaderInterface
  15. {
  16.     /**
  17.      * @var EventDispatcherInterface
  18.      */
  19.     private $eventDispatcher;
  20.     /**
  21.      * @var NavigationLoaderInterface
  22.      */
  23.     private $navigationLoader;
  24.     public function __construct(EventDispatcherInterface $eventDispatcherNavigationLoaderInterface $navigationLoader)
  25.     {
  26.         $this->eventDispatcher $eventDispatcher;
  27.         $this->navigationLoader $navigationLoader;
  28.     }
  29.     /**
  30.      * @throws CategoryNotFoundException
  31.      * @throws InconsistentCriteriaIdsException
  32.      * @throws MissingRequestParameterException
  33.      */
  34.     public function load(Request $requestSalesChannelContext $context): MenuOffcanvasPagelet
  35.     {
  36.         $navigationId $request->query->get('navigationId'$context->getSalesChannel()->getNavigationCategoryId());
  37.         if (!$navigationId) {
  38.             throw new MissingRequestParameterException('navigationId');
  39.         }
  40.         $navigation $this->navigationLoader->load($navigationId$context$navigationId1);
  41.         $pagelet = new MenuOffcanvasPagelet($navigation);
  42.         $this->eventDispatcher->dispatch(
  43.             new MenuOffcanvasPageletLoadedEvent($pagelet$context$request)
  44.         );
  45.         return $pagelet;
  46.     }
  47. }