About The function of ServiceListenerFactory in ZF2

I am reading the source code of Zend Framework 2’s (ZF2) ServiceManager to help me learn the Service Locator design pattern. However, when I came across the ServiceListenerFactory class, I couldn’t understand the role it plays in the overall design.
ServiceListenerFactory is responsible for loading configurations and creating ServiceListener instances, ensuring that services can be dynamically registered and created. The mapping relationship: ServiceListenerFactory maps configurations into the ServiceManager, enabling service factories to correctly create service instances based on the configurations.

<?php
namespace ZendMvcService;
use ZendModuleManagerListenerServiceListener;
use ZendModuleManagerListenerServiceListenerInterface;
use ZendMvcExceptionInvalidArgumentException;
use ZendMvcExceptionRuntimeException;
use ZendServiceManagerFactoryInterface;
use ZendServiceManagerServiceLocatorInterface;

class ServiceListenerFactory implements FactoryInterface
{
    const MISSING_KEY_ERROR = 'Invalid service listener options detected, %s array must contain %s key.';
    const VALUE_TYPE_ERROR = 'Invalid service listener options detected, %s must be a string, %s given.';

    protected $defaultServiceConfig = array(      /*Default mvc-related service configuration -- can be overridden by modules.
        'invokables' => array(
            'DispatchListener'     => 'ZendMvcDispatchListener',
            'RouteListener'        => 'ZendMvcRouteListener',
            'SendResponseListener' => 'ZendMvcSendResponseListener'
        ),
        'factories' => array(
            'Application'                    => 'ZendMvcServiceApplicationFactory',
            'Config'                         => 'ZendMvcServiceConfigFactory',
            'ControllerLoader'               => 'ZendMvcServiceControllerLoaderFactory',
            'ControllerPluginManager'        => 'ZendMvcServiceControllerPluginManagerFactory',
            'ConsoleAdapter'                 => 'ZendMvcServiceConsoleAdapterFactory',
            'ConsoleRouter'                  => 'ZendMvcServiceRouterFactory',
            'ConsoleViewManager'             => 'ZendMvcServiceConsoleViewManagerFactory',
            'DependencyInjector'             => 'ZendMvcServiceDiFactory',
            'DiAbstractServiceFactory'       => 'ZendMvcServiceDiAbstractServiceFactoryFactory',
            'DiServiceInitializer'           => 'ZendMvcServiceDiServiceInitializerFactory',
            'DiStrictAbstractServiceFactory' => 'ZendMvcServiceDiStrictAbstractServiceFactoryFactory',
            'FilterManager'                  => 'ZendMvcServiceFilterManagerFactory',
            'FormElementManager'             => 'ZendMvcServiceFormElementManagerFactory',
            'HttpRouter'                     => 'ZendMvcServiceRouterFactory',
            'HttpViewManager'                => 'ZendMvcServiceHttpViewManagerFactory',
            'HydratorManager'                => 'ZendMvcServiceHydratorManagerFactory',
            'InputFilterManager'             => 'ZendMvcServiceInputFilterManagerFactory',
            'MvcTranslator'                  => 'ZendMvcServiceTranslatorServiceFactory',
            'PaginatorPluginManager'         => 'ZendMvcServicePaginatorPluginManagerFactory',
            'Request'                        => 'ZendMvcServiceRequestFactory',
            'Response'                       => 'ZendMvcServiceResponseFactory',
            'Router'                         => 'ZendMvcServiceRouterFactory',
            'RoutePluginManager'             => 'ZendMvcServiceRoutePluginManagerFactory',
            'SerializerAdapterManager'       => 'ZendMvcServiceSerializerAdapterPluginManagerFactory',
            'ValidatorManager'               => 'ZendMvcServiceValidatorManagerFactory',
            'ViewHelperManager'              => 'ZendMvcServiceViewHelperManagerFactory',
            'ViewFeedRenderer'               => 'ZendMvcServiceViewFeedRendererFactory',
            'ViewFeedStrategy'               => 'ZendMvcServiceViewFeedStrategyFactory',
            'ViewJsonRenderer'               => 'ZendMvcServiceViewJsonRendererFactory',
            'ViewJsonStrategy'               => 'ZendMvcServiceViewJsonStrategyFactory',
            'ViewManager'                    => 'ZendMvcServiceViewManagerFactory',
            'ViewResolver'                   => 'ZendMvcServiceViewResolverFactory',
            'ViewTemplateMapResolver'        => 'ZendMvcServiceViewTemplateMapResolverFactory',
            'ViewTemplatePathStack'          => 'ZendMvcServiceViewTemplatePathStackFactory',
        ),
        'aliases' => array(
            'Configuration'                          => 'Config',
            'Console'                                => 'ConsoleAdapter',
            'Di'                                     => 'DependencyInjector',
            'ZendDiLocatorInterface'               => 'DependencyInjector',
            'ZendMvcControllerPluginManager'      => 'ControllerPluginManager',
            'ZendViewResolverTemplateMapResolver' => 'ViewTemplateMapResolver',
            'ZendViewResolverTemplatePathStack'   => 'ViewTemplatePathStack',
            'ZendViewResolverAggregateResolver'   => 'ViewResolver',
            'ZendViewResolverResolverInterface'   => 'ViewResolver',
        ),
        'abstract_factories' => array(
            'ZendFormFormAbstractServiceFactory',
        ),
    );
    /*Create the service listener service
     *Tries to get a service named ServiceListenerInterface from the service locator, otherwise creates a 
*ZendModuleManagerListenerServiceListener service, passing it the service locator instance and the default service
     * configuration, which can be overridden by modules.
     *It looks for the 'service_listener_options' key in the application config and tries to add service manager as configured. The value of
     * 'service_listener_options' must be a list (array) which contains the following keys:
     *   - service_manager: the name of the service manage to create as string
     *   - config_key: the name of the configuration key to search for as string
     *   - interface: the name of the interface that modules can implement as string
     *   - method: the name of the method that modules have to implement as string
     * @param  ServiceLocatorInterface  $serviceLocator
     * @return ServiceListener
     * @throws InvalidArgumentException For invalid configurations.   * @throws RuntimeException*/
    public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $configuration   = $serviceLocator->get('ApplicationConfig');

        if ($serviceLocator->has('ServiceListenerInterface')) {
            $serviceListener = $serviceLocator->get('ServiceListenerInterface');

            if (!$serviceListener instanceof ServiceListenerInterface) {
                throw new RuntimeException( 'The service named ServiceListenerInterface must implement ' .
                    'ZendModuleManagerListenerServiceListenerInterface'
                );
            }
            $serviceListener->setDefaultServiceConfig($this->defaultServiceConfig);
        } else {
            $serviceListener = new ServiceListener($serviceLocator, $this->defaultServiceConfig);
        }
        if (isset($configuration['service_listener_options'])) {
            if (!is_array($configuration['service_listener_options'])) {
                throw new InvalidArgumentException(sprintf( 'The value of service_listener_options must be an array, %s given.',
                    gettype($configuration['service_listener_options'])
                ));
            }

            foreach ($configuration['service_listener_options'] as $key => $newServiceManager) {
                if (!isset($newServiceManager['service_manager'])) {
                    throw new InvalidArgumentException(sprintf(self::MISSING_KEY_ERROR, $key, 'service_manager'));
                } elseif (!is_string($newServiceManager['service_manager'])) {
                    throw new InvalidArgumentException(sprintf(self::VALUE_TYPE_ERROR, 'service_manager',
                        gettype($newServiceManager['service_manager'])
                    ));
                }
                if (!isset($newServiceManager['config_key'])) {
                    throw new InvalidArgumentException(sprintf(self::MISSING_KEY_ERROR, $key, 'config_key'));
                } elseif (!is_string($newServiceManager['config_key'])) {
                    throw new InvalidArgumentException(sprintf(self::VALUE_TYPE_ERROR, 'config_key',
                        gettype($newServiceManager['config_key'])
                    ));
                }
                if (!isset($newServiceManager['interface'])) {
                    throw new InvalidArgumentException(sprintf(self::MISSING_KEY_ERROR, $key, 'interface'));
                } elseif (!is_string($newServiceManager['interface'])) {
                    throw new InvalidArgumentException(sprintf(self::VALUE_TYPE_ERROR, 'interface',
                        gettype($newServiceManager['interface'])
                    ));
                }
                if (!isset($newServiceManager['method'])) {
                    throw new InvalidArgumentException(sprintf(self::MISSING_KEY_ERROR, $key, 'method'));
                } elseif (!is_string($newServiceManager['method'])) {
                    throw new InvalidArgumentException(sprintf( self::VALUE_TYPE_ERROR, 'method',
                        gettype($newServiceManager['method'])
                    ));
                }

                $serviceListener->addServiceManager(
                    $newServiceManager['service_manager'],
                    $newServiceManager['config_key'],
                    $newServiceManager['interface'],
                    $newServiceManager['method']
                );
            }
        }
        return $serviceListener;
    }
}

Please tell me its role If you can also provide the relevant code in the ServiceManager, that would be even better!