src/DI/EventDispatcherExtension.php
private function doBeforeCompileLaziness(): void
	{
		$builder = $this->getContainerBuilder();
		$dispatcher = $builder->getDefinition($this->prefix('dispatcher'));

		$subscribers = $builder->findByType(EventSubscriberInterface::class);
		foreach ($subscribers as $name => $subscriber) {
			$events = call_user_func([$subscriber->getEntity(), 'getSubscribedEvents']);

			/**
			 * ['eventName' => 'methodName']
			 * ['eventName' => ['methodName', $priority]]
			 * ['eventName' => [['methodName1', $priority], ['methodName2']]]
			 */
			foreach ($events as $event => $args) {
				if (is_string($args)) {
					if (!method_exists((string) $subscriber->getType(), $args)) {
						throw new ServiceCreationException(sprintf('Event listener %s does not have callable method %s', $subscriber->getType(), $args));
					}

					$dispatcher->addSetup('addSubscriberLazy', [$event, $name]);
				} elseif (is_string($args[0])) {
					if (!method_exists((string) $subscriber->getType(), $args[0])) {
						throw new ServiceCreationException(sprintf('Event listener %s does not have callable method %s', $subscriber->getType(), $args[0]));
					}

					$dispatcher->addSetup('addSubscriberLazy', [$event, $name]);
				} else {
					foreach ($args as $arg) {
						if (!method_exists((string) $subscriber->getType(), $arg[0])) {
							throw new ServiceCreationException(sprintf('Event listener %s does not have callable method %s', $subscriber->getType(), $arg[0]));
						}

						$dispatcher->addSetup('addSubscriberLazy', [$event, $name]);
					}
				}
			}
		}
	}
private function doBeforeCompileLaziness(): void
	{
		$builder = $this->getContainerBuilder();
		$dispatcher = $builder->getDefinition($this->prefix('dispatcher'));

		$subscribers = $builder->findByType(EventSubscriberInterface::class);
		foreach ($subscribers as $name => $subscriber) {
			$events = call_user_func([$subscriber->getEntity(), 'getSubscribedEvents']);

			/**
			 * ['eventName' => 'methodName']
			 * ['eventName' => ['methodName', $priority]]
			 * ['eventName' => [['methodName1', $priority], ['methodName2']]]
			 */
			foreach ($events as $event => $args) {
				if (is_string($args)) {
					if (!method_exists((string) $subscriber->getType(), $args)) {
						throw new ServiceCreationException(sprintf('Event listener %s does not have callable method %s', $subscriber->getType(), $args));
					}

					$dispatcher->addSetup('addSubscriberLazy', [$event, $name]);
				} elseif (is_string($args[0])) {
					if (!method_exists((string) $subscriber->getType(), $args[0])) {
						throw new ServiceCreationException(sprintf('Event listener %s does not have callable method %s', $subscriber->getType(), $args[0]));
					}

					$dispatcher->addSetup('addSubscriberLazy', [$event, $name]);
				} else {
					foreach ($args as $arg) {
						if (!method_exists((string) $subscriber->getType(), $arg[0])) {
							throw new ServiceCreationException(sprintf('Event listener %s does not have callable method %s', $subscriber->getType(), $arg[0]));
						}

						$dispatcher->addSetup('addSubscriberLazy', [$event, $name]);
					}
				}
			}
		}
	}
private function doBeforeCompileLaziness ( ) : void { $ builder = $ this -> getContainerBuilder ( ) ; $ dispatcher = $ builder -> getDefinition ( $ this -> prefix ( 'dispatcher' ) ) ; $ subscribers = $ builder -> findByType ( EventSubscriberInterface :: class ) ; foreach ( $ subscribers as $ name => $ subscriber ) { $ events = call_user_func ( [ $ subscriber -> getEntity ( ) , 'getSubscribedEvents' ] ) ; /**
			 * ['eventName' => 'methodName']
			 * ['eventName' => ['methodName', $priority]]
			 * ['eventName' => [['methodName1', $priority], ['methodName2']]]
			 */ foreach ( $ events as $ event => $ args ) { if ( is_string ( $ args ) ) { if ( ! method_exists ( ( string ) $ subscriber -> getType ( ) , $ args ) ) { throw new ServiceCreationException ( sprintf ( 'Event listener %s does not have callable method %s' , $ subscriber -> getType ( ) , $ args ) ) ; } $ dispatcher -> addSetup ( 'addSubscriberLazy' , [ $ event , $ name ] ) ; } elseif ( is_string ( $ args [ 0 ] ) ) { if ( ! method_exists ( ( string ) $ subscriber -> getType ( ) , $ args [ 0 ] ) ) { throw new ServiceCreationException ( sprintf ( 'Event listener %s does not have callable method %s' , $ subscriber -> getType ( ) , $ args [ 0 ] ) ) ; } $ dispatcher -> addSetup ( 'addSubscriberLazy' , [ $ event , $ name ] ) ; } else { foreach ( $ args as $ arg ) { if ( ! method_exists ( ( string ) $ subscriber -> getType ( ) , $ arg [ 0 ] ) ) { throw new ServiceCreationException ( sprintf ( 'Event listener %s does not have callable method %s' , $ subscriber -> getType ( ) , $ arg [ 0 ] ) ) ; } $ dispatcher -> addSetup ( 'addSubscriberLazy' , [ $ event , $ name ] ) ; } } } } }
Collect listeners and subscribers in lazy-way
Collect listeners and subscribers in lazy - way