vendor/shopware/core/Framework/Event/NestedEventDispatcher.php line 32

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Framework\Event;
  3. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. class NestedEventDispatcher implements EventDispatcherInterface
  6. {
  7.     /**
  8.      * @var EventDispatcherInterface
  9.      */
  10.     private $dispatcher;
  11.     public function __construct(EventDispatcherInterface $dispatcher)
  12.     {
  13.         $this->dispatcher $dispatcher;
  14.     }
  15.     public function dispatch($event, ?string $eventName null): object
  16.     {
  17.         if ($event instanceof NestedEvent && $events $event->getEvents()) {
  18.             foreach ($events as $nested) {
  19.                 $name null;
  20.                 if ($nested instanceof GenericEvent) {
  21.                     $name $nested->getName();
  22.                 }
  23.                 $this->dispatch($nested$name);
  24.             }
  25.         }
  26.         return $this->dispatcher->dispatch($event$eventName);
  27.     }
  28.     /**
  29.      * @param callable $listener can not use native type declaration @see https://github.com/symfony/symfony/issues/42283
  30.      */
  31.     public function addListener(string $eventName$listenerint $priority 0): void
  32.     {
  33.         $this->dispatcher->addListener($eventName$listener$priority);
  34.     }
  35.     public function addSubscriber(EventSubscriberInterface $subscriber): void
  36.     {
  37.         $this->dispatcher->addSubscriber($subscriber);
  38.     }
  39.     /**
  40.      * @param callable $listener can not use native type hint as it is incompatible with symfony <5.3.4
  41.      */
  42.     public function removeListener(string $eventName$listener): void
  43.     {
  44.         $this->dispatcher->removeListener($eventName$listener);
  45.     }
  46.     public function removeSubscriber(EventSubscriberInterface $subscriber): void
  47.     {
  48.         $this->dispatcher->removeSubscriber($subscriber);
  49.     }
  50.     public function getListeners(?string $eventName null): array
  51.     {
  52.         return $this->dispatcher->getListeners($eventName);
  53.     }
  54.     /**
  55.      * @param callable $listener can not use native type hint as it is incompatible with symfony <5.3.4
  56.      */
  57.     public function getListenerPriority(string $eventName$listener): ?int
  58.     {
  59.         return $this->dispatcher->getListenerPriority($eventName$listener);
  60.     }
  61.     public function hasListeners(?string $eventName null): bool
  62.     {
  63.         return $this->dispatcher->hasListeners($eventName);
  64.     }
  65. }