Create service with name

@param ServiceLocatorInterface $serviceLocator
@param $name
@param $requestedName
@return mixed
548356
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        $menu = strtolower(str_replace('DbNavigationMenu', '', $requestedName));

        $navigation = new DbNavigationFactory();
        $navigation->setName($menu);
        return $navigation->createService($serviceLocator);
    }
976586
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        $config = $this->getConfig($serviceLocator)[$requestedName];

        $resourceName = $config['resource_name'];

        /** @var $httpClient Client */
        $httpClient = isset($config['http_client']) && $serviceLocator->has($config['http_client']) ?
            $serviceLocator->get($config['http_client']) : null;

        /** @var $baseRequest Request */
        $baseRequest = isset($config['base_request']) && $serviceLocator->has($config['base_request']) ?
            $serviceLocator->get($config['base_request']) : null;

        $restClient = new RestClient($resourceName, $httpClient, $baseRequest);

        if (isset($config['uri_resource_strategy']) && $serviceLocator->has($config['uri_resource_strategy'])) {
            $restClient->setUriResourceStrategy($serviceLocator->get($config['uri_resource_strategy']));
        }

        // Array of int code valid
        if (isset($config['valid_status_code']) && is_array($config['valid_status_code'])) {
            $restClient->setValidStatusCodes($config['valid_status_code']);
        }
        // string json/xml
        if (isset($config['request_format'])) {
            $restClient->setRequestFormat($config['request_format']);
        }
        // Profiler
        if (isset($config['profiler']) && $serviceLocator->has($config['profiler'])) {
            $restClient->setProfiler($serviceLocator->get($config['profiler']));
        }

        return $restClient;
    }
505269
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $appServiceLocator = $serviceLocator;
        if ($appServiceLocator instanceof AbstractPluginManager) {
            $appServiceLocator->getServiceLocator();
        }

        /** @var ObjectManagerAutoDetectorInterface $objectManagerAutoDetector */
        $objectManagerAutoDetector = $appServiceLocator->get(ObjectManagerAutoDetectorInterface::class);

        /** @var DoctrineObjectManagerInterface $objectManager */
        $objectManager = $appServiceLocator->get(DoctrineObjectManagerInterface::class);


        return new DoctrineObjectHydratorLocator($objectManagerAutoDetector, $objectManager);
    }
1216068
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config = $this->getConfig($serviceLocator);

        if (!isset($config['cache'])) {
            return null;
        }

        $config = $config['cache'];
        /* @var $cache CacheProvider|Cache */
        $cache = null;
        $cacheFactory = $this->getCacheFactory($config);
        $cache = $cacheFactory->newInstance($config);

        if (isset($config['namespace'])) {
            $cache->setNamespace(trim($config['namespace']));
        }

        return $cache;
    }
851648
public static function factory(ContainerInterface $container, $requestedName, array $options=[])
    {
        $ob = new self($options);
        $ob->setContainer($container);
        return $ob;
    }
1122970
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        if (substr($name, -5) != 'table') {
            return false;
        }

        if (empty($this->config)) {
            $config = $serviceLocator->get('config');
            $this->config = isset($config['tables']) ? $config['tables'] : [];
        }

        if (!isset($this->config[$requestedName])) {
            return false;
        }

        return true;
    }
1120614
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        /** @var ModuleOptionsPluginManagerInterface $moduleOptionsManager */
        $moduleOptionsManager = $serviceLocator->get(ModuleOptionsPluginManagerInterface::class);

        /** @var DoctrineObjectManagerInterface $doctrineObjectManager */
        $doctrineObjectManager = $serviceLocator->get(DoctrineObjectManagerInterface::class);

        return new ObjectManagerAutoDetector($moduleOptionsManager, $doctrineObjectManager);
    }
461444
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $routeCollection = new RouteCollection();
        $requestContext  = $serviceLocator->get('RouterRequestContext');
        $routerOptions   = array();

        $logger = $serviceLocator->has('logger') ? $serviceLocator->get('Logger') : null;

        $router = new Router($requestContext, $routeCollection, $routerOptions, $logger);

        // @todo - consider making a base router class, and then have a ModuleRouterFactory to pull module routes
        // @todo - find a way to set routes on this after we instantiate this factory

        // @todo - let you add new routes on demand and call $router->setRouteCollection()
        return $router;
    }
442040
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        $appServiceLocator = $serviceLocator;
        if ($serviceLocator instanceof AbstractPluginManager) {
            $appServiceLocator = $serviceLocator->getServiceLocator();
        }

        return $appServiceLocator->has($requestedName);
    }
515854
public function createServiceWithName(
        ServiceLocatorInterface $serviceLocator,
        $name,
        $requestedName
    ) {
        return new BaseController(
            $serviceLocator->getServiceLocator()->get('Config'),
            $requestedName,
            $serviceLocator
        );
    }
41220
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        if ($serviceLocator instanceof AbstractPluginManager && $serviceLocator->getServiceLocator()) {
            $serviceLocator = $serviceLocator->getServiceLocator();
        }

        $config = $this->getConfig($serviceLocator);
        if (empty($config)) {
            return false;
        }

        return (
            isset($config[$requestedName])
            && is_array($config[$requestedName])
            && !empty($config[$requestedName])
            && isset($config[$requestedName]['datagateway'])
            && is_string($config[$requestedName]['datagateway'])
            && !empty($config[$requestedName]['datagateway'])
            && $serviceLocator->has($config[$requestedName]['datagateway'])
            && isset($config[$requestedName]['resultset'])
            && is_string($config[$requestedName]['resultset'])
            && !empty($config[$requestedName]['resultset'])
            && $serviceLocator->has($config[$requestedName]['resultset'])
        );
    }
1022944
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $className = $this->getClassName();
        $keyName   = $this->getKeyName();
        $config    = $serviceLocator->get('config');
        $options   = isset($config[$keyName]) ? $config[$keyName] : [];
        return new $className($options);
    }
67769
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        //--------------------------------
        //data steps
        //  fetch
        //  filter
        //  sanitize
        //  parse
        //--------------------------------
        $fetch  = new FetchApplicationOutput();
        $dump   = new DumpConfigurationContent();

        $fetch->setCommand(new Command());
        $dump->setTimestamp(time());

        $pipe = new Pipe(
            //fetch data
            $fetch,
            //filter data
            new RemoveFirstLinesAndLastLine(),
            new RemoveColorsAndModuleHeadlines(),
            //sanitize data
            new RemoveIndexDotPhpFromLines(),
            //parse data
            new ParseToConfiguration(),
            $dump
        );

        return $pipe;
    }
1043882
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $service = new InstalledPuppetModuleCacheManager();

        /** @var PuppetModule $puppetModuleService */
        $puppetModuleService = $serviceLocator->get('KmbPmProxy\Service\PuppetModule');
        $service->setPuppetModuleService($puppetModuleService);

        return $service;
    }
157696
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $context = new RequestContext();
        $context->fromRequest($serviceLocator->get('Request'));

        return $context;
    }
473218
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        if (substr($requestedName, 0, 11) != 'FileStorage') {
            return false;
        }
        if (!($configs = $this->getConfigs($serviceLocator))) {
            return false;
        }

        return isset($configs[$requestedName]);
    }
153791
protected function createServiceClient(string $name, array $options = []): ServiceInterface
    {
        $entry = $this->manifest->getService($name);
        # we check for the manifest entry
        if (empty($entry)) {
            throw new ResourceNotFoundException('Could not find the client for the requested service '.$name);
        }
        $service = $entry['namespace'] . '\\' . $entry['client'];
        return new $service($this, $options);
    }