private function processEvents()
	{
		$builder = $this->getContainerBuilder();

		$eventManager = $builder->addDefinition($this->prefix('eventManager'))
			->setClass(EventManager::class);

		$entityListenerResolver = $builder->addDefinition($this->prefix('entityListenerResolver'))
			->setClass(ContainerEntityListenerResolver::class);

		$rc = new \ReflectionClass(Events::class);
		$events = $rc->getConstants();

		foreach ($this->config['listeners'] as $event => $listeners) {
			if (!isset($events[$event])) {
				throw new InvalidStateException("Event '$event' is not valid doctrine event. See class "
					. Events::class . ' for list of available events.');
			}
			foreach ((array) $listeners as $listener) {
				$builder->getDefinition($this->prefix('eventManager'))->addSetup('$service->addEventListener(['
					. Events::class . '::?], ?)', [$event, $listener]);
			}
		}
	}