src/M6Web/Bundle/ElasticsearchBundle/DependencyInjection/M6WebElasticsearchExtension.php
protected function createHandler(ContainerBuilder $container, array $config, $definitionId)
    {
        // cURL handler
        $singleHandler   = (new Definition('GuzzleHttp\Ring\Client\CurlHandler'))
            ->setPublic(false);

        $this->setFactoryToDefinition('Elasticsearch\ClientBuilder', 'defaultHandler', $singleHandler);

        $singleHandlerId = $definitionId.'.single_handler';
        $container->setDefinition($singleHandlerId, $singleHandler);

        // Headers handler
        $headersHandler = (new Definition('M6Web\Bundle\ElasticsearchBundle\Handler\HeadersHandler'))
            ->setPublic(false)
            ->setArguments([new Reference($singleHandlerId)]);
        if (isset($config['headers'])) {
            foreach ($config['headers'] as $key => $value) {
                $headersHandler->addMethodCall('setHeader', [$key, $value]);
            }
        }
        $headersHandlerId = $definitionId.'.headers_handler';
        $container->setDefinition($headersHandlerId, $headersHandler);

        // Event handler
        $eventHandler   = (new Definition('M6Web\Bundle\ElasticsearchBundle\Handler\EventHandler'))
            ->setPublic(false)
            ->setArguments([new Reference('event_dispatcher'), new Reference($headersHandlerId)]);
        $eventHandlerId = $definitionId.'.event_handler';
        $container->setDefinition($eventHandlerId, $eventHandler);

        return $eventHandlerId;
    }
protected function createHandler(ContainerBuilder $container, array $config, $definitionId)
    {
        // cURL handler
        $singleHandler   = (new Definition('GuzzleHttp\Ring\Client\CurlHandler'))
            ->setPublic(false);

        $this->setFactoryToDefinition('Elasticsearch\ClientBuilder', 'defaultHandler', $singleHandler);

        $singleHandlerId = $definitionId.'.single_handler';
        $container->setDefinition($singleHandlerId, $singleHandler);

        // Headers handler
        $headersHandler = (new Definition('M6Web\Bundle\ElasticsearchBundle\Handler\HeadersHandler'))
            ->setPublic(false)
            ->setArguments([new Reference($singleHandlerId)]);
        if (isset($config['headers'])) {
            foreach ($config['headers'] as $key => $value) {
                $headersHandler->addMethodCall('setHeader', [$key, $value]);
            }
        }
        $headersHandlerId = $definitionId.'.headers_handler';
        $container->setDefinition($headersHandlerId, $headersHandler);

        // Event handler
        $eventHandler   = (new Definition('M6Web\Bundle\ElasticsearchBundle\Handler\EventHandler'))
            ->setPublic(false)
            ->setArguments([new Reference('event_dispatcher'), new Reference($headersHandlerId)]);
        $eventHandlerId = $definitionId.'.event_handler';
        $container->setDefinition($eventHandlerId, $eventHandler);

        return $eventHandlerId;
    }
protected function createHandler ( ContainerBuilder $ container , array $ config , $ definitionId ) { // cURL handler $ singleHandler = ( new Definition ( 'GuzzleHttp\Ring\Client\CurlHandler' ) ) -> setPublic ( false ) ; $ this -> setFactoryToDefinition ( 'Elasticsearch\ClientBuilder' , 'defaultHandler' , $ singleHandler ) ; $ singleHandlerId = $ definitionId . '.single_handler' ; $ container -> setDefinition ( $ singleHandlerId , $ singleHandler ) ; // Headers handler $ headersHandler = ( new Definition ( 'M6Web\Bundle\ElasticsearchBundle\Handler\HeadersHandler' ) ) -> setPublic ( false ) -> setArguments ( [ new Reference ( $ singleHandlerId ) ] ) ; if ( isset ( $ config [ 'headers' ] ) ) { foreach ( $ config [ 'headers' ] as $ key => $ value ) { $ headersHandler -> addMethodCall ( 'setHeader' , [ $ key , $ value ] ) ; } } $ headersHandlerId = $ definitionId . '.headers_handler' ; $ container -> setDefinition ( $ headersHandlerId , $ headersHandler ) ; // Event handler $ eventHandler = ( new Definition ( 'M6Web\Bundle\ElasticsearchBundle\Handler\EventHandler' ) ) -> setPublic ( false ) -> setArguments ( [ new Reference ( 'event_dispatcher' ) , new Reference ( $ headersHandlerId ) ] ) ; $ eventHandlerId = $ definitionId . '.event_handler' ; $ container -> setDefinition ( $ eventHandlerId , $ eventHandler ) ; return $ eventHandlerId ; }
Create request handler

@param ContainerBuilder $container
@param array            $config
@param string           $definitionId

@return string
Create request handler