Create service with name

@param ServiceLocatorInterface $serviceLocator
@param                         $name
@param                         $requestedName
@return mixed
338502
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        $factory = new NavigationFactory($requestedName);
        return $factory->createService($serviceLocator);
    }
1230531
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $appServiceLocator = $serviceLocator instanceof AbstractPluginManager ? $serviceLocator->getServiceLocator() : $serviceLocator;

        /** @var array $appConfig */
        $appConfig = $appServiceLocator->get('config');
        $moduleConfig = array_key_exists(Module::CONFIG_KEY, $appConfig) ? $appConfig[Module::CONFIG_KEY] : [];

        return new ModuleOptions($moduleConfig);
    }
442040
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        $appServiceLocator = $serviceLocator;
        if ($serviceLocator instanceof AbstractPluginManager) {
            $appServiceLocator = $serviceLocator->getServiceLocator();
        }

        return $appServiceLocator->has($requestedName);
    }
1132209
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        if ($serviceLocator instanceof ServiceLocatorAwareInterface) {
            $serviceLocator = $serviceLocator->getServiceLocator();
        }

        /** @var ServiceLocatorInterface $domainManager */
        $domainManager = $serviceLocator->get('MamuzBlog\DomainManager');
        /** @var \MamuzBlogFeed\Options\ConfigProviderInterface $configProvider */
        $configProvider = $domainManager->get('MamuzBlogFeed\Options\ConfigProvider');

        $queryFilter = new Query($configProvider);

        return new QueryFilterAggregate($queryFilter);
    }
1146010
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        $config = $serviceLocator->get('Config');
        if (!isset($config) || !isset($config[$this->configKey])) {
            return false;
        }
        return (isset($config[$this->configKey][$requestedName]) && is_array($config[$this->configKey][$requestedName]));
    }
457589
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        /**
         * @var array $config
         */
        $config = $serviceLocator->get('config');

        /**
         * @var \Zend\View\HelperPluginManager $serverUrl
         */
        $serverUrl = $serviceLocator->get('ViewHelperManager');

        /**
         * @var \Zend\Mvc\I18n\Translator $translator
         */
        $translator = $serviceLocator->get('translator');

        return new Search(
            $config,
            $serverUrl,
            $translator
        );
    }
1221418
public function canCreateServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        return $this->getContainer($serviceLocator)->has($requestedName);
    }
311418
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        if ($serviceLocator instanceof ServiceLocatorAwareInterface) {
            $serviceLocator = $serviceLocator->getServiceLocator();
        }

        /** @var \Zend\Mvc\Application $application */
        $application = $serviceLocator->get('Application');
        $mvcEvent = $application->getMvcEvent();

        /** @var ServiceLocatorInterface $domainManager */
        $domainManager = $serviceLocator->get('MamuzBlog\DomainManager');
        /** @var \MamuzBlog\Feature\TagQueryInterface $tagQueryService */
        $tagQueryService = $domainManager->get('MamuzBlog\Service\TagQuery');

        return new TagList($mvcEvent, $tagQueryService);
    }
827687
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        /** @var array $appConfig */
        $appConfig = $serviceLocator->get('config');
        $config = [];
        if (array_key_exists(Module::CONFIG_KEY, $appConfig)) {
            $config = $appConfig[Module::CONFIG_KEY];
        }
        $moduleOptions = new ModuleOptions($config);
        return $moduleOptions;
    }
1349551
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        $serviceManager = $serviceLocator instanceof AbstractPluginManager ?
            $serviceLocator->getServiceLocator() : $serviceLocator;

        $config = $serviceManager->get('config');

        $dataMapperSpec      = $config['thorr_persistence_dmm']['doctrine']['adapters'][$requestedName];
        $dataMapperClassName = is_string($dataMapperSpec) ? $dataMapperSpec : $dataMapperSpec['class'];

        $entityClass = array_search($requestedName, $config['thorr_persistence_dmm']['entity_data_mapper_map']);

        $objectManagerServiceName = isset($dataMapperSpec['object_manager']) ? $dataMapperSpec['object_manager'] : null;

        $objectManager = $this->getObjectManagerService($serviceManager, $objectManagerServiceName);

        $instance = new $dataMapperClassName($entityClass, $objectManager);

        if (! $instance instanceof DoctrineAdapter) {
            throw new Exception\ServiceNotCreatedException(sprintf(
                'Invalid data mapper type: "%s" is not a subtype of "%s"',
                $dataMapperClassName,
                DoctrineAdapter::class
            ));
        }

        return $instance;
    }
233868
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $config = $serviceLocator->get('Config');

        return new FormAnnotationBuilder(
            isset($config['form_annotation_builder'])
                ? $config['form_annotation_builder']
                : null
            );
    }
117415
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
    {
        if ($serviceLocator instanceof AbstractPluginManager && $serviceLocator->getServiceLocator()) {
            $serviceLocator = $serviceLocator->getServiceLocator();
        }

        $config = $this->getConfig($serviceLocator)[$requestedName];
        $dataGataway = $serviceLocator->get($config['datagateway']);
        /* @var $resultSetPrototype \Matryoshka\Model\ResultSet\ResultSetInterface */
        $resultSetPrototype = $serviceLocator->get($config['resultset']);

        if (isset($config['buffered_resultset']) && $config['buffered_resultset']) {
            /* @var $resultSetPrototype \Matryoshka\Model\ResultSet\AbstractResultSet */
            $resultSetPrototype = new BufferedResultSet($resultSetPrototype);
        }

        //Create a model instance
        $class = $this->modelClass;
        if (!empty($config['type']) && is_string($config['type'])) {
            if (!is_subclass_of($config['type'], $class)) {
                throw new Exception\UnexpectedValueException(sprintf(
                    '"type" in model configuration must be a subclass of "%s": "%s" given',
                    $class,
                    $config['type']
                ));
            }

            $class = $config['type'];
        }

        /* @var $model \Matryoshka\Model\Model */
        $model =  new $class($dataGataway, $resultSetPrototype);

        //Setup Hydrator
        $hydrator = null;
        if (!empty($config['hydrator']) && is_string($config['hydrator'])) {
            $hydrator = $this->getHydratorByName($serviceLocator, $config['hydrator']);
            $model->setHydrator($hydrator);
        }

        if ($hydrator && $resultSetPrototype instanceof HydratorAwareInterface) {
            $resultSetPrototype->setHydrator($hydrator);
        }

        //Setup InputFilter
        if (!empty($config['input_filter']) && is_string($config['input_filter'])) {
            $model->setInputFilter($this->getInputFilterByName($serviceLocator, $config['input_filter']));
        }

        //Setup Paginator
        if (!empty($config['paginator_criteria']) && is_string($config['paginator_criteria'])) {
            $model->setPaginatorCriteria($this->getPaginatorCriteriaByName(
                $serviceLocator,
                $config['paginator_criteria']
            ));
        }

        //Setup Object Prototype
        if (!empty($config['object']) && is_string($config['object'])) {
            $resultSetPrototype->setObjectPrototype($this->getObjectByName($serviceLocator, $config['object']));
        }

        //Setup Prototype strategy
        if (!empty($config['prototype_strategy']) && is_string($config['prototype_strategy'])) {
            if ($resultSetPrototype instanceof PrototypeStrategyAwareInterface) {
                $resultSetPrototype->setPrototypeStrategy(
                    $this->getPrototypeStrategyByName($serviceLocator, $config['prototype_strategy'])
                );
            }
        }

        //Setup listeners
        if (!empty($config['listeners']) && is_array($config['listeners'])) {
            if ($model instanceof ObservableModel) {
                /** @var $model ObservableModel */
                $this->injectListeners($serviceLocator, $config['listeners'], $model);
            } else {
                throw new Exception\ServiceNotCreatedException(sprintf(
                    'Instance of model must be a subclass of "%s" in order to attach listeners',
                    ObservableModel::class
                ));
            }
        }

        return $model;
    }
53246
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        if ($serviceLocator instanceof ServiceLocatorAwareInterface) {
            $serviceLocator = $serviceLocator->getServiceLocator();
        }

        /** @var \Zend\ServiceManager\ServiceLocatorInterface $viewHelperManager */
        $viewHelperManager = $serviceLocator->get('ViewHelperManager');
        /** @var \Zend\View\Helper\HeadLink $headLink */
        $headLink = $viewHelperManager->get('HeadLink');
        /** @var ServiceLocatorInterface $domainManager */
        $domainManager = $serviceLocator->get('MamuzBlog\DomainManager');
        /** @var \MamuzBlogFeed\Feed\Writer\BuilderInterface $builder */
        $builder = $domainManager->get('MamuzBlogFeed\Feed\WriterFactory');
        /** @var \MamuzBlogFeed\Options\ConfigProviderInterface $configProvider */
        $configProvider = $domainManager->get('MamuzBlogFeed\Options\ConfigProvider');

        return new HeadLinkAggregate($headLink, $builder, $configProvider);
    }
985031
public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $serviceName, $requestedName)
    {
        if (!isset($this->allowedServiceNames[$requestedName])) {
            throw new Exception\InvalidServiceNameException('Service "' . $requestedName . '" is not whitelisted');
        }


        if ($serviceLocator instanceof AbstractPluginManager) {
            /* @var $serviceLocator AbstractPluginManager */
            $this->serviceLocator = $serviceLocator->getServiceLocator();
        } else {
            $this->serviceLocator = $serviceLocator;
        }

        return parent::get($requestedName);
    }
1332811
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        /** @var ModuleOptionsPluginManagerInterface $moduleOptionsPluginManager */
        $moduleOptionsPluginManager = $serviceLocator->get(ModuleOptionsPluginManagerInterface::class);

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

        $metadataReaderCacheServiceName = $moduleOptions->getMetadataReaderCache();

        /** @var Cache $metadataReaderCache */
        $metadataReaderCache = $serviceLocator->get($metadataReaderCacheServiceName);

        $reader = new AnnotationReader();
        $reader = new CachedReader($reader, $metadataReaderCache);

        return new DiscriminatorEntryListener($reader);
    }
442536
public function createService(ServiceLocatorInterface $serviceManager)
    {
        $serviceLocator = $serviceManager->getServiceLocator();

        return $this->__invoke($serviceLocator, null);
    }
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;
    }