custom/plugins/CogiMobileMenu/src/Subscriber/MobileMenuSubscriber.php line 44

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Cogi\MobileMenu\Subscriber;
  3. use Shopware\Core\Content\Category\Service\NavigationLoaderInterface;
  4. use Shopware\Core\System\SystemConfig\SystemConfigService;
  5. use Shopware\Storefront\Event\StorefrontRenderEvent;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. class MobileMenuSubscriber implements EventSubscriberInterface
  8. {
  9.     /**
  10.      * @var NavigationLoaderInterface
  11.      */
  12.     private $navigationLoader;
  13.     /**
  14.      * @var SystemConfigService
  15.      */
  16.     private $systemConfigService;
  17.     /**
  18.      * @param NavigationLoaderInterface $navigationLoader
  19.      * @param SystemConfigService $systemConfigService
  20.      */
  21.     public function __construct(
  22.         NavigationLoaderInterface $navigationLoader,
  23.         SystemConfigService $systemConfigService
  24.     )
  25.     {
  26.         $this->navigationLoader $navigationLoader;
  27.         $this->systemConfigService $systemConfigService;
  28.     }
  29.     /**
  30.      * @return string[]
  31.      */
  32.     public static function getSubscribedEvents(): array
  33.     {
  34.         return [
  35.             StorefrontRenderEvent::class => 'addMobileMenuFooterMenu'
  36.         ];
  37.     }
  38.     public function addMobileMenuFooterMenu(StorefrontRenderEvent $event)
  39.     {
  40.         $navigationId $this->systemConfigService->get('CogiMobileMenu.config.footerNavigationEntryPoint');
  41.         if ($navigationId) {
  42.             $tree $this->navigationLoader->load($navigationId$event->getSalesChannelContext(), $navigationId);
  43.             $event->setParameter('cogiMobileMenuFooterNavigationEntryPoint'$tree);
  44.         }
  45.     }
  46. }