Create service with name

@param ServiceLocatorInterface $serviceLocator
@param $name
@param $requestedName

@throws \RuntimeException
@return mixed
976717
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        $config = $this->config[$requestedName];
        $dbAdapter = $serviceLocator->get(isset($config['adapter']) ? $config['adapter'] : 'db');

        /** @var \Zend\Db\TableGateway\TableGateway $table */
        if (isset($config['schema'])) {
            $config['table'] = new TableIdentifier($config['table'], $config['schema']);
        }

        $featureSet = new Feature\FeatureSet();
        $featureSet->addFeature(new Feature\CommonCallFeature($config['primary']));

        if (isset($config['invokable'])) {
            if (!class_exists($config['invokable'])) {
                throw new \RuntimeException("Class '{$config['invokable']}' not found ");
            }
            $table = new $config['invokable']($config['table'], $dbAdapter, $featureSet);
        } else {
            $table = new TableGateway($config['table'], $dbAdapter, $featureSet);
        }

        if (isset($config['row'])) {
            if ($config['row'] === true) {
                $config['row'] = 'Zend\Db\RowGateway\RowGateway';
            }

            if (is_string($config['row'])) {
                if (!class_exists($config['row'])) {
                    throw new \RuntimeException("Class '{$config['row']}' not found ");
                }

                $rowGatewayPrototype = new $config['row'](
                    $config['primary'],
                    $config['table'],
                    $dbAdapter, $table->getSql()
                );
            } else if (is_object($config['row'])) {
                $rowGatewayPrototype = $config['row'];
            } else {
                throw new \InvalidArgumentException('Error row argument');
            }

            $table->getResultSetPrototype()->setArrayObjectPrototype($rowGatewayPrototype);
        }

        return $table;
    }
1175703
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        try {
            $di = $this->getDiContainer($serviceLocator);
        } catch (\Exception $e) {
            return false;
        }

        $class = str_replace('.', '\\', $requestedName);
        if (class_exists($class) || $di->instanceManager()->hasAlias($requestedName)) {
            return true;
        }

        return false;
    }
469457
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        return substr($requestedName, - strlen(self::$termination)) === self::$termination && array_key_exists($this->removeTermination($requestedName), $this->getFormaterIndex($serviceLocator));
    }
716865
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        /** @var array  $appConfig */
        $appConfig = $serviceLocator->get('config');
        $doctrineConfig = array_key_exists('doctrine', $appConfig) ? $appConfig['doctrine'] : [];

        /** @var ModuleOptionsPluginManagerInterface $moduleOptionsManager */
        $moduleOptionsManager = $serviceLocator->get(ModuleOptionsPluginManagerInterface::class);
        /** @var ModuleOptionsInterface $moduleOptions */
        $moduleOptions = $moduleOptionsManager->get(ModuleOptionsInterface::class);

        return new DoctrineOrmModuleConfig($doctrineConfig, $moduleOptions);
    }
128212
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config = $serviceLocator->get('config');

        if (!is_array($config)) {
            throw new \RuntimeException("Expected application config to be an array. Got " . gettype($config));
        }

        if (! isset($config['system_data_dir'])) {
            throw new \RuntimeException("Missing system_data_dir key in application configuration. Please add the key to your config and point it to the data directory of your application!");
        }

        return DataLocation::fromPath($serviceLocator->get('config')['system_data_dir']);
    }
782535
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        /**
         * @var \Zend\ServiceManager\ServiceLocatorAwareTrait $serviceLocator
         */
        $sl = $serviceLocator->getServiceLocator();

        /**
         * @var \Mp3\Form\Search $formSearch
         */
        $formSearch = $sl->get('FormElementManager')
                         ->get('Mp3\Form\Search');

        /**
         * @var \Mp3\Service\Index $serviceIndex
         */
        $serviceIndex = $sl->get('Mp3\Service\Index');

        return new IndexController(
            $formSearch,
            $serviceIndex
        );
    }
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;
    }
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;
    }
1194664
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        if (!array_key_exists($requestedName, $this->dataForModuleOptionsCreate)) {
            if (!$serviceLocator instanceof ModuleOptionsPluginManagerInterface) {
                return false;
            }
            /** @var ModuleOptionsPluginManagerInterface $serviceLocator  */
            $this->buildDataForModuleOptionsCreate($serviceLocator, $requestedName);
        }

        return false !== $this->dataForModuleOptionsCreate[$requestedName];
    }
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]);
    }
1341686
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config = $serviceLocator->get('Config');
        $appConfigConfiguration = isset($config['rumeaulib_appconfig']) ? $config['rumeaulib_appconfig'] : [];

        $service = new AppConfig($serviceLocator, $appConfigConfiguration);

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

        $defaultSender = isset($config['default_sender']) ? $config['default_sender'] : null;
        $aliasSender = isset($config['alias_sender']) ? $config['alias_sender'] : null;
        $transport = Factory::create($config['transport']);

        $serviceClient = new MailService($transport, $defaultSender);
        $serviceClient->setAdditionalInfo(isset($config['additional_info']) ? $config['additional_info'] : []);

        return $serviceClient;
    }
649546
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        if (null === $this->workflowServiceNamePrefix) {
            $this->workflowServiceNamePrefix = $this->buildWorkflowServiceNamePrefix($serviceLocator);
        }

        $flag = 0 === strpos($requestedName, $this->workflowServiceNamePrefix) && strlen($requestedName) > strlen($this->workflowServiceNamePrefix);
        return $flag;
    }
208920
protected function createControllerWithName(ServiceLocatorInterface $services, $requestedName)
    {
        $options = $this->getOptions($requestedName, $services);

        $controllerType = $options->getControllerType() ?: RestfulController::class;

        return new $controllerType(
            $services->get('DomainServiceManager')->get($requestedName),
            $options
        );
    }
213691
public function createDelegatorWithName(
        ServiceLocatorInterface $serviceLocator,
        $name,
        $requestedName,
        $callback
    ) {
        $viewHelper = $callback();

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

        return $viewHelper;
    }
977571
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        try {
            $identifiers = self::splitIntoIdentifiers($requestedName);
        } catch (ProcessException $e) {
            return false;
        }
        
        return $this->getDatatypesHandler($serviceLocator)->hasDataType($identifiers['mode'], $identifiers['type'], $identifiers['endpoint']);
    }
1221418
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        return $this->getContainer($serviceLocator)->has($requestedName);
    }