src/M6Web/Bundle/ElasticsearchBundle/DependencyInjection/M6WebElasticsearchExtension.php
protected function createElasticsearchClient(ContainerBuilder $container, $name, $config)
    {
        $definitionId = 'm6web_elasticsearch.client.'.$name;

        $handlerId = $this->createHandler($container, $config, $definitionId);

        $clientConfig = [
            'hosts'   => $config['hosts'],
            'handler' => new Reference($handlerId),
        ];

        if (isset($config['retries'])) {
            $clientConfig['retries'] = $config['retries'];
        }

        if (isset($config['logger'])) {
            $clientConfig['logger'] = new Reference($config['logger']);
        }

        if (!empty($config['connectionPoolClass'])) {
            $clientConfig['connectionPool'] = $config['connectionPoolClass'];
        }

        if (!empty($config['selectorClass'])) {
            $clientConfig['selector'] = $config['selectorClass'];
        }

        if (!empty($config['connectionParams'])) {
            $clientConfig['connectionParams'] = $config['connectionParams'];
        }

        $definition = (new Definition($config['client_class']))
            ->setArguments([$clientConfig]);
        $this->setFactoryToDefinition($config['clientBuilderClass'], 'fromConfig', $definition);

        $container->setDefinition($definitionId, $definition);

        if ($container->getParameter('kernel.debug')) {
            $this->createDataCollector($container);
        }
    }
protected function createElasticsearchClient(ContainerBuilder $container, $name, $config)
    {
        $definitionId = 'm6web_elasticsearch.client.'.$name;

        $handlerId = $this->createHandler($container, $config, $definitionId);

        $clientConfig = [
            'hosts'   => $config['hosts'],
            'handler' => new Reference($handlerId),
        ];

        if (isset($config['retries'])) {
            $clientConfig['retries'] = $config['retries'];
        }

        if (isset($config['logger'])) {
            $clientConfig['logger'] = new Reference($config['logger']);
        }

        if (!empty($config['connectionPoolClass'])) {
            $clientConfig['connectionPool'] = $config['connectionPoolClass'];
        }

        if (!empty($config['selectorClass'])) {
            $clientConfig['selector'] = $config['selectorClass'];
        }

        if (!empty($config['connectionParams'])) {
            $clientConfig['connectionParams'] = $config['connectionParams'];
        }

        $definition = (new Definition($config['client_class']))
            ->setArguments([$clientConfig]);
        $this->setFactoryToDefinition($config['clientBuilderClass'], 'fromConfig', $definition);

        $container->setDefinition($definitionId, $definition);

        if ($container->getParameter('kernel.debug')) {
            $this->createDataCollector($container);
        }
    }
protected function createElasticsearchClient ( ContainerBuilder $ container , $ name , $ config ) { $ definitionId = 'm6web_elasticsearch.client.' . $ name ; $ handlerId = $ this -> createHandler ( $ container , $ config , $ definitionId ) ; $ clientConfig = [ 'hosts' => $ config [ 'hosts' ] , 'handler' => new Reference ( $ handlerId ) , ] ; if ( isset ( $ config [ 'retries' ] ) ) { $ clientConfig [ 'retries' ] = $ config [ 'retries' ] ; } if ( isset ( $ config [ 'logger' ] ) ) { $ clientConfig [ 'logger' ] = new Reference ( $ config [ 'logger' ] ) ; } if ( ! empty ( $ config [ 'connectionPoolClass' ] ) ) { $ clientConfig [ 'connectionPool' ] = $ config [ 'connectionPoolClass' ] ; } if ( ! empty ( $ config [ 'selectorClass' ] ) ) { $ clientConfig [ 'selector' ] = $ config [ 'selectorClass' ] ; } if ( ! empty ( $ config [ 'connectionParams' ] ) ) { $ clientConfig [ 'connectionParams' ] = $ config [ 'connectionParams' ] ; } $ definition = ( new Definition ( $ config [ 'client_class' ] ) ) -> setArguments ( [ $ clientConfig ] ) ; $ this -> setFactoryToDefinition ( $ config [ 'clientBuilderClass' ] , 'fromConfig' , $ definition ) ; $ container -> setDefinition ( $ definitionId , $ definition ) ; if ( $ container -> getParameter ( 'kernel.debug' ) ) { $ this -> createDataCollector ( $ container ) ; } }
Add a new Elasticsearch client definition in the container

@param ContainerBuilder $container
@param string           $name
@param array            $config
Add a new Elasticsearch client definition in the container