vendor/crehler/advanced-menu/src/Subscriber/HeaderPageletSubscriber.php line 33

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\Subscriber;
  13. use Crehler\AdvancedMenu\Service\ProductsNavigationLoader;
  14. use Shopware\Storefront\Pagelet\Header\HeaderPageletLoadedEvent;
  15. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  16. class HeaderPageletSubscriber implements EventSubscriberInterface
  17. {
  18.     protected ProductsNavigationLoader $productsNavigationLoader;
  19.     public function __construct(ProductsNavigationLoader $productsNavigationLoader)
  20.     {
  21.         $this->productsNavigationLoader $productsNavigationLoader;
  22.     }
  23.     public static function getSubscribedEvents()
  24.     {
  25.         return [HeaderPageletLoadedEvent::class => 'onHeaderPageletLoaded'];
  26.     }
  27.     public function onHeaderPageletLoaded(HeaderPageletLoadedEvent $event): void
  28.     {
  29.         $event->getPagelet()->addExtension('productsCategory'$this->productsNavigationLoader->loadProductCategory($event->getSalesChannelContext()));
  30.     }
  31. }