vendor/shopware/platform/src/Core/Framework/Event/NestedEventDispatcher.php line 20

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.     public function addListener(string $eventName$listenerint $priority 0): void
  29.     {
  30.         $this->dispatcher->addListener($eventName$listener$priority);
  31.     }
  32.     public function addSubscriber(EventSubscriberInterface $subscriber): void
  33.     {
  34.         $this->dispatcher->addSubscriber($subscriber);
  35.     }
  36.     public function removeListener(string $eventName$listener): void
  37.     {
  38.         $this->dispatcher->removeListener($eventName$listener);
  39.     }
  40.     public function removeSubscriber(EventSubscriberInterface $subscriber): void
  41.     {
  42.         $this->dispatcher->removeSubscriber($subscriber);
  43.     }
  44.     public function getListeners(?string $eventName null): array
  45.     {
  46.         return $this->dispatcher->getListeners($eventName);
  47.     }
  48.     public function getListenerPriority(string $eventName$listener): ?int
  49.     {
  50.         return $this->dispatcher->getListenerPriority($eventName$listener);
  51.     }
  52.     public function hasListeners(?string $eventName null): bool
  53.     {
  54.         return $this->dispatcher->hasListeners($eventName);
  55.     }
  56. }