addMapper($this->container->get(ArrayMapper::class)) ->addMapper($this->container->get(EventAttributeMapper::class)) ->addMapper($this->getListenerAttributeMapper()); // Create dispatcher instance $dispatcher = new EventDispatcher($provider); // Set the dispatcher and provider instances to the container $app ->set(ListenerProviderInterface::class, $provider) ->set(EventDispatcherInterface::class, $dispatcher); } private function getListenerAttributeMapper(): ListenerAttributeMapper { /** @var ListenerAttributeMapper */ $mapper = $this->container->get(ListenerAttributeMapper::class); $this->enableCaching && !$this->enableDebugging ? $mapper->enableCaching() : $mapper->disableCaching(); return $mapper; } }