public function createService(ServiceLocatorInterface $serviceLocator, $name = null)
    {
        $config = $serviceLocator->get('Config');

        if (! $config['ocra_service_manager']['logged_service_manager']) {
            return $serviceLocator;
        }

        /* @var $proxyFactory \ProxyManager\Factory\AccessInterceptorScopeLocalizerFactory */
        $proxyFactory = $serviceLocator->get('OcraServiceManager\\ServiceManager\\AccessInterceptorProxyFactory');
        /* @var $locatorInterceptors \Closure[] */
        $locatorInterceptors = $serviceLocator->get('OcraServiceManager\\ServiceManager\\AccessInterceptors');

        // @todo maybe this should be a callback, and `locatorInterceptors` should not be used explicitly
        $proxyLocator = $proxyFactory->createProxy($serviceLocator, array(), $locatorInterceptors);

        if (! ($name && $serviceLocator instanceof ServiceManager)) {
            return $proxyLocator;
        }

        // @todo this service hardcoding should be removed
        $allowOverrides = $serviceLocator->getAllowOverride();

        $serviceLocator->setAllowOverride(true);
        $serviceLocator->setService('ServiceManager', $proxyLocator);
        $serviceLocator->setAllowOverride($allowOverrides);

        return $proxyLocator;
    }