Attain Client Instance from LazyConfigs

@param $clientName

@return MongoDB\Client
@throws \Exception
347807
protected function _attainClient($clientName)
    {
        if (! isset($this->lazyClientOptions[$clientName]) )
            throw new \Exception(sprintf('MongoDB Client (%s) not Registered.', $clientName));


        $conf = $this->lazyClientOptions[$clientName];
        if (! isset($conf['host']) )
            throw new \Exception(sprintf(
                '"host" Option for Client (%s) not given.'
                , $clientName
                , \Poirot\Std\flatten($conf)
            ));

        $uri        = $conf['host'];
        $uriOptions = (isset($conf['options_uri']))    ? $conf['options_uri']    : array();
        $options    = (isset($conf['options_driver'])) ? $conf['options_driver'] : array();

        $client = new MongoDB\Client($uri, $uriOptions, $options);
        return $client;
    }
754480
public function getInstance($className)
    {
        switch ($className) {
            case '\\Zepi\\Core\\Utils\\Manager\\ConfigurationManager':
                if ($this->configurationManager === null) {
                    $path = $this->framework->getRootDirectory() . '/config/framework.json';
                    $configFileBackend = new \Zepi\Core\Utils\Backend\ConfigurationFileBackend($path);
                    
                    $this->configurationManager = $this->framework->initiateObject($className, array(
                        'configurationFileBackend' => $configFileBackend
                    ));
                    $this->configurationManager->loadConfigurationFile();
                }
                
                return $this->configurationManager;
            break;
            
            default: 
                return $this->framework->initiateObject($className);
            break;
        }
    }
596007
protected function createClient($client)
    {
        try {
            new \ReflectionClass($client);
        } catch (\ReflectionException $e) {
            throw new FoundationException(sprintf("Could not load class '%s'.", $client), null, $e);
        }

        $client_instance = new $client();

        return $client_instance;
    }
1091078
public function getElasticSearchClient()
    {
        $config = $this->getElasticConfig();

        // elasticsearch v2.0 using builder
        if (class_exists('\Elasticsearch\ClientBuilder')) {
            return \Elasticsearch\ClientBuilder::fromConfig($config);
        }

        // elasticsearch v1
        return new \Elasticsearch\Client($config);
    }
464831
public function client(array $config)
    {
        $key = $this->getClientKey($config);

        if (isset($this->clients[$key])) {
            return $this->clients[$key];
        }

        return $this->clients[$key] = $this->createClient($config);
    }
1343704
public function getClient()
    {
        if ($this->client === null) {
            $this->client = new Client([
                'base_uri' => $this->config['base_uri'],
            ]);
        }

        return $this->client;
    }
854358
public function createCommand($indexName, $clientName = null)
    {
        if (!in_array($indexName, $this->indexInformer->getAllIndexNames())) {
            $this->outputFormatted("The index <b>%s</b> is not configured in the current application", [$indexName]);
            $this->quit(1);
        }

        $client = $this->clientFactory->create($clientName);
        try {
            $index = new Index($indexName, $client);
            if ($index->exists()) {
                $this->outputFormatted("The index <b>%s</b> exists", [$indexName]);
                $this->quit(1);
            }
            $index->create();
            $this->outputFormatted("Index <b>%s</b> created with success", [$indexName]);
        } catch (Exception $exception) {
            $this->outputFormatted("Unable to create an index named: <b>%s</b>", [$indexName]);
            $this->quit(1);
        }
    }
1204189
public function get($indexName)
	{
		$index = $this->getRegistered($indexName);

		$params = [
			'index' => $index->getInternalName()
		];

		return $this->elasticSearcher->getClient()->indices()->getMapping($params);
	}
994167
public function getMongoClient()
    {
        if ($this->mongoClient) {
            return $this->mongoClient;
        }

        $this->mongoClient = new \MongoClient(
            $this->dsn,
            $this->connectOptions
        );
        
        return $this->mongoClient;
    }
914968
public function get($instanceName) {
		if (!isset($this->objectInstances[$instanceName]) || $this->objectInstances[$instanceName] == null) {
			$this->instantiateComponent($instanceName);
		}
		return $this->objectInstances[$instanceName];
	}
707668
public function getInstance($addonName) {
        if (!$this->isStarted($addonName)) {
            throw new \Exception("Tried to get instance of inactive addon '{$addonName}'");
        }

        if (!array_key_exists($addonName, $this->instances) || !($this->instances[$addonName] instanceof AddonInterface)) {
            throw new \Exception("Addon '{$addonName}' has no instance");
        }

        return $this->instances[$addonName];
    }
502087
private function initClient() {
		if(isset($_COOKIE[self::CLIENT_INFO_COOKIE])) {
			$clientData = @json_decode(base64_decode($_COOKIE[self::CLIENT_INFO_COOKIE], true), true);
			if(!$clientData) {
				throw new \Exception('Wrong format of response cookie data: ' . $_COOKIE[self::CLIENT_INFO_COOKIE]);
			}

			$client = new Client($clientData);
			if(isset($clientData['auth'])) {
				$client->auth = new ClientAuth($clientData['auth']);
			}
			return $client;
		}
	}
816285
private function getClient(): Client
    {
        if (null !== $this->client) {
            return $this->client;
        }

        return $this->client = new Client(
            $this->config['carrier'],
            $this->config['key'],
            $this->config['cache'],
            $this->config['debug']
        );
    }
320786
public function client($alias)
    {
        if (is_int($alias) && isset($this->clients[$alias])) {
            return $this->clients[$alias];
        } elseif (isset($this->aliases[$alias])) {
            return $this->aliases[$alias];
        }
        throw new Exception("Client $alias does not exist.");
    }
560033
public function _($name = null)
    {
        if (isset($name)) {
            $this->path[] = $name;
        }
        $client = new static($this->host, $this->headers);
        $client->setPath($this->path);
        $client->setCurlOptions($this->curlOptions);
        $client->setRetryOnLimit($this->retryOnLimit);
        $this->path = [];

        return $client;
    }
624095
private function createElasticClient($clientName, ContainerBuilder $container)
    {
        // Storage metadata
        $smfName = sprintf('%s.metadata', $clientName);
        $definition = new Definition(
            Utility::getLibraryClass('Search\Elastic\StorageMetadataFactory')
        );
        $definition->setPublic(false);
        $container->setDefinition($smfName, $definition);

        // Client
        return new Definition(
            Utility::getLibraryClass('Search\Elastic\Client'),
            [new Reference($smfName)]
        );
    }
125612
public function getClient($name)
    {
        if (!isset($this->serverArray[$name])) {
            $name   = $this->defaultName;
        }

        if (isset($this->clientArray[$name])) {
            try {
                $this->clientArray[$name]->ping();
            } catch (\RedisException $ex) {
                $this->clientArray[$name] = $this->createClient($this->serverArray[$name]);
            }
            return $this->clientArray[$name];
        }

        $this->clientArray[$name] = $this->createClient($this->serverArray[$name]);
        return $this->clientArray[$name];
    }