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

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.     /**
  12.      * @internal
  13.      */
  14.     public function __construct(EventDispatcherInterface $dispatcher)
  15.     {
  16.         $this->dispatcher $dispatcher;
  17.     }
  18.     public function dispatch($event, ?string $eventName null): object
  19.     {
  20.         if ($event instanceof NestedEvent && $events $event->getEvents()) {
  21.             foreach ($events as $nested) {
  22.                 $name null;
  23.                 if ($nested instanceof GenericEvent) {
  24.                     $name $nested->getName();
  25.                 }
  26.                 $this->dispatch($nested$name);
  27.             }
  28.         }
  29.         return $this->dispatcher->dispatch($event$eventName);
  30.     }
  31.     /**
  32.      * @param callable $listener can not use native type declaration @see https://github.com/symfony/symfony/issues/42283
  33.      */
  34.     public function addListener(string $eventName$listenerint $priority 0): void
  35.     {
  36.         $this->dispatcher->addListener($eventName$listener$priority);
  37.     }
  38.     public function addSubscriber(EventSubscriberInterface $subscriber): void
  39.     {
  40.         $this->dispatcher->addSubscriber($subscriber);
  41.     }
  42.     /**
  43.      * @param callable $listener can not use native type hint as it is incompatible with symfony <5.3.4
  44.      */
  45.     public function removeListener(string $eventName$listener): void
  46.     {
  47.         $this->dispatcher->removeListener($eventName$listener);
  48.     }
  49.     public function removeSubscriber(EventSubscriberInterface $subscriber): void
  50.     {
  51.         $this->dispatcher->removeSubscriber($subscriber);
  52.     }
  53.     public function getListeners(?string $eventName null): array
  54.     {
  55.         return $this->dispatcher->getListeners($eventName);
  56.     }
  57.     /**
  58.      * @param callable $listener can not use native type hint as it is incompatible with symfony <5.3.4
  59.      */
  60.     public function getListenerPriority(string $eventName$listener): ?int
  61.     {
  62.         return $this->dispatcher->getListenerPriority($eventName$listener);
  63.     }
  64.     public function hasListeners(?string $eventName null): bool
  65.     {
  66.         return $this->dispatcher->hasListeners($eventName);
  67.     }
  68. }