Determine if we can create a service with name

@param ServiceLocatorInterface $serviceLocator
@param $name
@param $requestedName
@return bool
541499
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        $config = $this->getConfig($serviceLocator);

        if (empty($config)) {
            return false;
        }

        $serviceConfig = $this->checkHasRequestedNameConfig($config, $requestedName);
        $transportConfig = $this->checkHasTransportConfig($config, $requestedName, $serviceLocator);

        return $serviceConfig && $transportConfig;
    }
484742
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName) {
        $interface = 'oat\search\base\command\OperatorConverterInterface';
        return (class_exists($requestedName) && in_array($interface , class_implements($requestedName)));
    }
548356
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        $menu = strtolower(str_replace('DbNavigationMenu', '', $requestedName));

        $navigation = new DbNavigationFactory();
        $navigation->setName($menu);
        return $navigation->createService($serviceLocator);
    }
578912
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        if ($serviceLocator instanceof ServiceLocatorAwareInterface) {
            $serviceLocator = $serviceLocator->getServiceLocator();
        }

        /** @var \Zend\View\HelperPluginManager $viewHelperManager */
        $viewHelperManager = $serviceLocator->get('ViewHelperManager');
        $optionsFilter = new FeedOptions($viewHelperManager->getRenderer());

        $config = $serviceLocator->get('Config')['MamuzBlogFeed'];
        return new ConfigProvider($config, $optionsFilter);
    }
75898
protected function getPaginatorCriteriaByName(ServiceLocatorInterface $serviceLocator, $name)
    {
        $criteria = $serviceLocator->get($name);
        if (!$criteria instanceof PaginableCriteriaInterface) {
            throw new Exception\ServiceNotCreatedException(sprintf(
                'Instance of type "%s" is invalid; must implement "%s"',
                (is_object($criteria) ? get_class($criteria) : gettype($criteria)),
                PaginableCriteriaInterface::class
            ));
        }
        return $criteria;
    }
880607
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        if ($serviceLocator instanceof AbstractPluginManager) {
            $serviceLocator = $serviceLocator->getServiceLocator();
        }

        $config = $this->getConfig($serviceLocator)[$requestedName];
        $imgManService = $serviceLocator->get($config['service']);

        if (!$imgManService instanceof ImageService) {
            throw new ServiceNotCreatedException(
                sprintf(
                    'service must be a instance of ImgMan\Service\ImageService given: %s',
                    is_object($imgManService) ? get_class($imgManService) : gettype($imgManService)
                )
            );
        }

        $resourceClass = $this->getResourceClassFromConfig($config, $requestedName);

        /* @var $resource \ImgMan\Apigility\Model\ImgManConnectedResource */
        $resource = new $resourceClass($imgManService);

        if (isset($config['idName'])) {
            $resource->setIdName($config['idName']);
        }

        if (isset($config['blobName'])) {
            $resource->setBlobName($config['blobName']);
        }

        return $resource;
    }
688368
public function isServiceLoaded(string $serviceName): bool {
        if($this->serviceExists($serviceName)) {
            if(in_array($serviceName, $this->getSelfReferenceNames()))
                return true;

            /** @var ContainerInterface $container */
            $container = $this->serviceData[$serviceName];
            return $container->isInstanceLoaded();
        }
        return false;
    }
781624
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        /** @var $config ProcessingConfig */
        $config = $serviceLocator->get("processing_config");

        $connector = $config->getConnectors()[$requestedName];


        if (! isset($connector['dbal_connection'])) throw new \InvalidArgumentException(sprintf('Missing dbal_connection for sql connector %s', $requestedName));
        if (! isset($connector['table'])) throw new \InvalidArgumentException(sprintf('Missing table definition for sql connector %s', $requestedName));

        $appConfig = $serviceLocator->get('config');


        if (! isset($appConfig['prooph.link.sqlconnector']['connections'][$connector['dbal_connection']])) throw new \InvalidArgumentException(sprintf('The DBAL connection %s can not be found. Please check config/autoload/sqlconnector.local.php!', $connector['dbal_connection']));

        $actionEventDispatcher = null;
        $listeners = null;

        if (isset($appConfig['prooph.link.sqlconnector']['action_listeners'][$requestedName])) {
            $actionEventDispatcher = new Zf2ActionEventDispatcher([$requestedName]);

            if (! is_array($appConfig['prooph.link.sqlconnector']['action_listeners'][$requestedName])) {
                throw new \InvalidArgumentException(
                    sprintf(
                        "Key prooph.link.sqlconnector.action_listeners.$requestedName of config should be of type array. Got %s",
                        gettype($appConfig['prooph.link.sqlconnector']['action_listeners'][$requestedName])
                    )
                );
            }

            foreach ($appConfig['prooph.link.sqlconnector']['action_listeners'][$requestedName] as $listenerAlias) {
                $listenerAggregate = $serviceLocator->get($listenerAlias);

                if (! $listenerAggregate instanceof ActionEventListenerAggregate) {
                    throw new \InvalidArgumentException(
                        sprintf(
                            "Action listeners for sqlconnector %s should be of type Prooph\\Common\\ActionEventListenerAggregate. Got %s",
                            $requestedName,
                            (is_object($listenerAggregate))? get_class($listenerAggregate) : gettype($listenerAggregate)
                        )
                    );
                }

                $listeners[] = $listenerAggregate;
            }
        }

        return new DoctrineTableGateway(
            DriverManager::getConnection($appConfig['prooph.link.sqlconnector']['connections'][$connector['dbal_connection']]),
            $connector['table'],
            $actionEventDispatcher,
            $listeners
        );
    }
590125
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        $config = $this->getConfig($serviceLocator)[$requestedName];

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

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

        $api = new HttpApi($httpClient, $baseRequest);

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

        return $api;
    }
91017
public function canCreate(\Interop\Container\ContainerInterface $container, $requestedName)
    {
        $this->getConfig($container, $requestedName);
        return isset($this->dependencies[$requestedName]);
    }
519999
public function canCreate(ContainerInterface $serviceLocator, $requestedName)
    {
        if (substr($requestedName, -6) == self::WIDGET_SUFFIX) {
            /** @var $util \PageBuilder\Util\Widget */
            $util     = $serviceLocator->get('util\widget');
            $widgetId = str_replace(self::WIDGET_SUFFIX, '', $requestedName);

            return $util->widgetExist($widgetId);
        }

        return false;
    }
455393
public function canCreateServiceWithName(
        ServiceLocatorInterface $serviceLocator,
        $name,
        $requestedName
    ) {
        $config = $serviceLocator->getServiceLocator()->get('Config');

        return isset($config['rcmPlugin'][$requestedName]);
    }
870687
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        if (is_null($this->cachedFileGateway)) {
            $this->cachedFileGateway = new FileGateway(
                $serviceLocator->get('prooph.link.fileconnector.file_type_adapter_manager'),
                $serviceLocator->get('prooph.link.fileconnector.filename_renderer'),
                $serviceLocator->get('prooph.link.app.location_translator')
            );
        }

        return $this->cachedFileGateway;
    }
17763
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        $config = $this->getConfig($serviceLocator);
        $config = $config[$requestedName];

        if (!isset($config['collectorFactory'])) {
            throw new MissingConfigurationException('Unable to create DataTable service: collectorFactory is missing');
        }

        if (!isset($config['columns']) || empty($config['columns'])) {
            throw new MissingConfigurationException('Unable to create DataTable service: columns are missing');
        }

        /** @var FactoryInterface $collectorFactory */
        $collectorFactory = new $config['collectorFactory'];

        $datatable = new DataTable(isset($config['id']) ? $config['id'] : $requestedName);
        $datatable->setCollector($collectorFactory->createService($serviceLocator));
        $columns = array();
        foreach ($config['columns'] as $columnConfig) {
            $columns[] = Column::factory($serviceLocator, $columnConfig);
        }
        $datatable->setColumns($columns);
        if (isset($config['classes'])) {
            $datatable->setClasses($config['classes']);
        }

        return $datatable;
    }
252034
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        try {
            $className = $this->getFormaterIndex($serviceLocator)[$this->removeTermination($requestedName)];
            $reflectionClass = new \ReflectionClass($className);
            $instance = $reflectionClass->newInstance();
        } catch (\Exception $e) {
            throw new ProcessException($reflectionClass, $e->getCode(), $e);
        }
        
        return $instance;
    }
1319332
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $service = new Environment();

        /** @var EnvironmentRepositoryInterface $environmentRepository */
        $environmentRepository = $serviceLocator->get('EnvironmentRepository');
        $service->setEnvironmentRepository($environmentRepository);

        return $service;
    }
213691
public function createDelegatorWithName(
        ServiceLocatorInterface $serviceLocator,
        $name,
        $requestedName,
        $callback
    ) {
        $viewHelper = $callback();

        if ($viewHelper instanceof FormStatic) {
            $viewHelper->addClass(ImageInterface::class, 'cmsImage');
        }

        return $viewHelper;
    }