Returns config for specific service

@param $serviceName

@return
@throws OAuthServiceException
978814
protected function loadConfig($serviceName)
    {
        if (!empty($this->config[$serviceName])) {
            return $this->config[$serviceName];
        } else {
            throw new OAuthServiceException('No configuration for ' . $serviceName . ' service');
        }
    }
687477
public static function getServiceName(ServiceInterface $oauthService)
    {
        if ($oauthService instanceof AbstractService) {
            return $oauthService->service();
        }

        return preg_replace('/^.*\\\\/', '', get_class($oauthService));
    }
1260477
private function findName($service, ServiceConfig $serviceConfig)
    {
        if ($serviceConfig->has(ServiceConfig::NAME)) {
            return $serviceConfig->get(ServiceConfig::NAME);
        } else {
            foreach ((array) $this->possibleNames as $possibleName) {
                if (isset($service[$possibleName])) {
                    return $possibleName;
                }
            }
        }

        return null;
    }
527639
protected function getOAuthServiceName()
    {
        $serviceName = $this->getPayloadData('service', $this->request->getParameter('service'));

        if (empty($serviceName)) {
            $state = $this->getPayloadData('state', $this->request->getParameter('state'));
            if (empty($state)) {
                $state = $this->getPayloadData('oauth_token', $this->request->getParameter('oauth_token'));
            }
            if (!empty($state)) {
                $key = BaseOAuthService::CACHE_KEY_PREFIX . $state;
                $serviceName = \Cache::pull($key);
            }
        }

        return $serviceName;
    }
204368
public function get($serviceKey)
    {
        $serviceId = $this->getServiceId($serviceKey);
        if (!isset($this->services[$serviceId])) {
            $this->services[$serviceId] = $this->load($serviceId, $serviceKey);
        }
        return $this->services[$serviceId];
    }
641335
public static final function toServiceFile(string $serviceName): string
    {
        $serviceFile = sprintf('%s/app/service/%s/%s.php', APP_DIR, $serviceName, $serviceName);
        if (!file_exists($serviceFile) && (
            $serviceName == (Service::SERVICE_MAIN . Service::SERVICE_NAME_SUFFIX)
                || $serviceName == (Service::SERVICE_FAIL . Service::SERVICE_NAME_SUFFIX))) {
            $serviceFile = sprintf('%s/app/service/_default/%s/%s.php', APP_DIR, $serviceName, $serviceName);
        }

        return $serviceFile;
    }
579548
private function instantiateService($serviceName)
    {
        // Make sure service is registered
        if (!$this->registeredServices->keyExists($serviceName)) {
            throw new ServiceManagerException(ServiceManagerException::SERVICE_DEFINITION_NOT_FOUND, [$serviceName]);
        }

        // Get service config from registered services array
        $config = $this->registeredServices->key($serviceName);

        // Check circular referencing
        if ($this->references->keyExists($serviceName)) {
            throw new ServiceManagerException(ServiceManagerException::SERVICE_CIRCULAR_REFERENCE, [$serviceName]);
        }

        // Set service name reference for circular referencing checks
        $this->references->key($serviceName, $serviceName);

        // Compile ConfigObject into ServiceConfig
        $configCompiler = new ConfigCompiler($serviceName, $config, $this->parameters);
        $this->compiledConfig->key($serviceName, $configCompiler->compile());

        /**
         * @var $config ServiceConfig
         */
        $config = $this->compiledConfig->key($serviceName);

        // Construct service container and get service instance
        $serviceCreator = new ServiceCreator($config);
        $service = $serviceCreator->getService();

        // Unset service name reference
        $this->references->removeKey($serviceName);

        // Store instance if this service has a CONTAINER scope
        if ($config->getScope() == ServiceScope::CONTAINER) {
            $this->instantiatedServices->key($serviceName, $service);
        }

        return $service;
    }
1062875
public function getConfigurationFile( $serverName, $login){
        $service = sprintf( self::API_VPN_USER_CONFIG, $serverName, $login);
        $rest = $this->getService( $service);
        $rest->getConfig()->setIsReturnToJsonDecode( false);
        $rest->setIsResponseToCheck( false);
        $rest->GET();

        return $rest->getCurlResponse();
    }
686317
private static function getBaseFromService($service, $serviceConfig)
    {
        if (isset($serviceConfig[0]['router-base']) && strlen($serviceConfig[0]['router-base']) > 0) {
            $base = $serviceConfig[0]['router-base'] . '/';
        } else {
            $parts = explode('.', $service);

            $entity = array_pop($parts);
            $module = $parts[1];

            $base = '/' . $module . '/' . $entity . '/';
        }

        return $base;
    }
165123
protected function getSubService($serviceName)
    {
        if ($this->_subService[$serviceName] instanceof Service) {
            return $this->_subService[$serviceName];
        } elseif (!isset($this->_subService[$serviceName])) {
            throw new InvalidConfigException("The {$this->getId()}Service required sub service component `{$serviceName}` is not found.");
        } else {
            $uniqueName = $this->getId() . '/' . $serviceName;
            $this->_subService[$serviceName] = Yii::createObject(array_merge($this->_subService[$serviceName], [
                'service' => $this,
            ]));
            if (!$this->_subService[$serviceName] instanceof Service) {
                throw new InvalidConfigException("The required sub service component `{$uniqueName}` must return
                    an object extends `\\wocenter\\core\\Service`.");
            }
            
            Yii::trace('Loading sub service: ' . $uniqueName, __METHOD__);
            
            return $this->_subService[$serviceName];
        }
    }
365800
public function getServiceDump($serviceName)
    {
        $this->assertServiceExist($serviceName);

        return [
            'class'      => get_class($this->services[$serviceName]['definition']),
            'arguments'  => $this->getRegisterServiceArguments($serviceName)
        ];
    }
1018476
public static function oneById($serviceName, $id)
	{
		if(!self::has($serviceName)) {
			return null;
		}
		/** @var ReadOneInterface $serviceInstance */
		$serviceInstance = self::get($serviceName);
		try {
			$result = $serviceInstance->oneById($id);
		} catch (NotFoundHttpException $e) {
			$result = null;
		}
		return $result;
	}
467667
public function initConnection($serviceName)
    {
        $connection = $this->clientFactory->createServiceClient($serviceName);
        $this->connectionPool[$serviceName] = $connection;

        return $this;
    }
727137
public function setService($serviceName)
    {
        if (!array_key_exists($serviceName, $this->servicesList)) {
            $serviceName = $this->defaultServiceName;
        }

        $this->service = new $this->servicesList[$serviceName];

        return $this;
    }
630767
public function getServiceConfig()
    {
        return [
            'aliases' => [
                //for controller/view helpers to work
                'Zend\Authentication\AuthenticationService' => 'ZF\MvcAuth\Authentication',
                //'Zend\Authentication\AuthenticationService' => 'KapSecurity\Authentication\AuthenticationService',
                //'ZF\OAuth2\Adapter\PdoAdapter' => 'KapSecurity\OAuth2\PdoAdapter'
            ],
            'factories' => array(
                //'KapSecurity\OAuth2\PdoAdapter' => 'KapSecurity\OAuth2\PdoAdapter',
                'KapSecurity\OAuth2\PdoAdapter' => function($services) {
                        $config = $services->get('Config');

                        if (!isset($config['zf-oauth2']['db']) || empty($config['zf-oauth2']['db'])) {
                            throw new \RuntimeException(
                                'The database configuration [\'zf-oauth2\'][\'db\'] for OAuth2 is missing'
                            );
                        }

                        $username = isset($config['zf-oauth2']['db']['username']) ? $config['zf-oauth2']['db']['username'] : null;
                        $password = isset($config['zf-oauth2']['db']['password']) ? $config['zf-oauth2']['db']['password'] : null;
                        $options  = isset($config['zf-oauth2']['db']['options']) ? $config['zf-oauth2']['db']['options'] : array();

                        $oauth2ServerConfig = array();
                        if (isset($config['zf-oauth2']['storage_settings']) && is_array($config['zf-oauth2']['storage_settings'])) {
                            $oauth2ServerConfig = $config['zf-oauth2']['storage_settings'];
                        }

                        return new OAuth2\PdoAdapter(array(
                            'dsn'      => $config['zf-oauth2']['db']['dsn'],
                            'username' => $username,
                            'password' => $password,
                            'options'  => $options,
                        ), $oauth2ServerConfig);
                    },
                'KapSecurity\Authentication\Adapter\AdapterManager' => function($sm) {
                        $config = $sm->get('Config');

                        $managerConfig = [];
                        if(!empty($config['authentication_adapter_manager']) && !empty($config['authentication_adapter_manager']['adapters'])) {
                            $managerConfig = $config['authentication_adapter_manager']['adapters'];
                        }

                        $ins = new AdapterManager(new Config($managerConfig), $sm->get('KapSecurity\Authentication\Options'));
                        return $ins;
                    },
                'KapSecurity\Authentication\AuthenticationService' => function($sm) {
                        $ins = new AuthenticationService(
                            $sm->get('KapSecurity\Authentication\Options'),
                            $sm->get('KapSecurity\\IdentityAuthenticationRepository'),
                            $sm->get('KapSecurity\\IdentityRepository'),
                            $sm->get('KapSecurity\Authentication\Adapter\AdapterManager')
                        );
                        $ins->setStorage(new NonPersistent());
                        return $ins;
                    },
                'KapSecurity\Authentication\Options' => function($sm) {
                        $config = $sm->get('Config');
                        $options = empty($config['authentication']) ? [] : $config['authentication'];
                        return new Options($options);
                    },
                'KapSecurity\\IdentityRepository' => function($sm) {
                        $ins = new IdentityRepository(
                            $sm->get('KapSecurity\V1\Rest\Identity\IdentityResource\Table')
                        );
                        return $ins;
                    },
                "KapSecurity\\V1\\Rest\\Identity\\IdentityResource" => function($sm) {
                        $ins = new \KapApigility\EntityRepositoryResource(
                            $sm->get('KapSecurity\\IdentityRepository')
                        );
                        return $ins;
                    },
                'KapSecurity\\IdentityAuthenticationRepository' => function($sm) {
                        $ins = new IdentityAuthenticationRepository(
                            $sm->get('KapSecurity\V1\Rest\IdentityAuthentication\IdentityAuthenticationResource\Table')
                        );
                        return $ins;
                    },
                "KapSecurity\\V1\\Rest\\IdentityAuthentication\\IdentityAuthenticationResource" => function($sm) {
                        $ins = new \KapApigility\EntityRepositoryResource(
                            $sm->get('KapSecurity\\IdentityAuthenticationRepository')
                        );
                        return $ins;
                    },
            )
        ];
    }
1358691
public function getService($name = null)
    {
        $name = $name ?: $this->defaultService;

        if (!$name) {
            throw new \RuntimeException(sprintf(
                'You must configure a default %s service, registered %s services: "%s"',
                $this->serviceType, $this->serviceType,
                implode('", "', array_keys($this->services))
            ));
        }

        if (isset($this->services[$name])) {
            return $this->services[$name];
        }

        $this->assertServiceExists($name);
        $this->services[$name] = $this->container->get($this->serviceMap[$name]);

        return $this->services[$name];
    }
723160
public static function createService($serviceName)
    {
        switch ($serviceName) {
            case self::SERVICE_REST:
                return new RestService();
            break;
            case self::SERVICE_SOAP:
                return new SoapService();
            break;
            case self::SERVICE_XMLRPC:
                return new XmlRpcService();
            break;
        }

        throw new \Exception(sprintf('Unknown service %s', $serviceName));
    }