src/DependencyInjection/EightPointsGuzzleExtension.php
public function load(array $configs, ContainerBuilder $container)
    {
        $configPath = implode(DIRECTORY_SEPARATOR, [__DIR__, '..', 'Resources', 'config']);
        $loader     = new XmlFileLoader($container, new FileLocator($configPath));

        $loader->load('services.xml');

        $configuration = new Configuration($this->getAlias(), $container->getParameter('kernel.debug'), $this->plugins);
        $config        = $this->processConfiguration($configuration, $configs);
        $logging       = $config['logging'] === true;
        $profiling     = $config['profiling'] === true;

        foreach ($this->plugins as $plugin) {
            $container->addObjectResource(new \ReflectionClass(get_class($plugin)));
            $plugin->load($config, $container);
        }

        if ($logging) {
            $this->defineTwigDebugExtension($container);
            $this->defineLogger($container);
            $this->defineDataCollector($container, $config['slow_response_time'] / 1000);
            $this->defineFormatter($container);
            $this->defineSymfonyLogFormatter($container);
            $this->defineSymfonyLogMiddleware($container);
        }

        foreach ($config['clients'] as $name => $options) {
            $argument = [
                'base_uri' => $options['base_url'],
                'handler'  => $this->createHandler($container, $name, $options, $logging, $profiling)
            ];

            // if present, add default options to the constructor argument for the Guzzle client
            if (isset($options['options']) && is_array($options['options'])) {
                foreach ($options['options'] as $key => $value) {
                    if ($value === null || (is_array($value) && count($value) === 0)) {
                        continue;
                    }

                    $argument[$key] = $value;
                }
            }

            $client = new Definition($options['class']);
            $client->addArgument($argument);
            $client->setPublic(true);
            $client->setLazy($options['lazy']);

            // set service name based on client name
            $serviceName = sprintf('%s.client.%s', $this->getAlias(), $name);
            $container->setDefinition($serviceName, $client);
        }
    }
public function load(array $configs, ContainerBuilder $container)
    {
        $configPath = implode(DIRECTORY_SEPARATOR, [__DIR__, '..', 'Resources', 'config']);
        $loader     = new XmlFileLoader($container, new FileLocator($configPath));

        $loader->load('services.xml');

        $configuration = new Configuration($this->getAlias(), $container->getParameter('kernel.debug'), $this->plugins);
        $config        = $this->processConfiguration($configuration, $configs);
        $logging       = $config['logging'] === true;
        $profiling     = $config['profiling'] === true;

        foreach ($this->plugins as $plugin) {
            $container->addObjectResource(new \ReflectionClass(get_class($plugin)));
            $plugin->load($config, $container);
        }

        if ($logging) {
            $this->defineTwigDebugExtension($container);
            $this->defineLogger($container);
            $this->defineDataCollector($container, $config['slow_response_time'] / 1000);
            $this->defineFormatter($container);
            $this->defineSymfonyLogFormatter($container);
            $this->defineSymfonyLogMiddleware($container);
        }

        foreach ($config['clients'] as $name => $options) {
            $argument = [
                'base_uri' => $options['base_url'],
                'handler'  => $this->createHandler($container, $name, $options, $logging, $profiling)
            ];

            // if present, add default options to the constructor argument for the Guzzle client
            if (isset($options['options']) && is_array($options['options'])) {
                foreach ($options['options'] as $key => $value) {
                    if ($value === null || (is_array($value) && count($value) === 0)) {
                        continue;
                    }

                    $argument[$key] = $value;
                }
            }

            $client = new Definition($options['class']);
            $client->addArgument($argument);
            $client->setPublic(true);
            $client->setLazy($options['lazy']);

            // set service name based on client name
            $serviceName = sprintf('%s.client.%s', $this->getAlias(), $name);
            $container->setDefinition($serviceName, $client);
        }
    }
public function load ( array $ configs , ContainerBuilder $ container ) { $ configPath = implode ( DIRECTORY_SEPARATOR , [ __DIR__ , '..' , 'Resources' , 'config' ] ) ; $ loader = new XmlFileLoader ( $ container , new FileLocator ( $ configPath ) ) ; $ loader -> load ( 'services.xml' ) ; $ configuration = new Configuration ( $ this -> getAlias ( ) , $ container -> getParameter ( 'kernel.debug' ) , $ this -> plugins ) ; $ config = $ this -> processConfiguration ( $ configuration , $ configs ) ; $ logging = $ config [ 'logging' ] === true ; $ profiling = $ config [ 'profiling' ] === true ; foreach ( $ this -> plugins as $ plugin ) { $ container -> addObjectResource ( new \ ReflectionClass ( get_class ( $ plugin ) ) ) ; $ plugin -> load ( $ config , $ container ) ; } if ( $ logging ) { $ this -> defineTwigDebugExtension ( $ container ) ; $ this -> defineLogger ( $ container ) ; $ this -> defineDataCollector ( $ container , $ config [ 'slow_response_time' ] / 1000 ) ; $ this -> defineFormatter ( $ container ) ; $ this -> defineSymfonyLogFormatter ( $ container ) ; $ this -> defineSymfonyLogMiddleware ( $ container ) ; } foreach ( $ config [ 'clients' ] as $ name => $ options ) { $ argument = [ 'base_uri' => $ options [ 'base_url' ] , 'handler' => $ this -> createHandler ( $ container , $ name , $ options , $ logging , $ profiling ) ] ; // if present, add default options to the constructor argument for the Guzzle client if ( isset ( $ options [ 'options' ] ) && is_array ( $ options [ 'options' ] ) ) { foreach ( $ options [ 'options' ] as $ key => $ value ) { if ( $ value === null || ( is_array ( $ value ) && count ( $ value ) === 0 ) ) { continue ; } $ argument [ $ key ] = $ value ; } } $ client = new Definition ( $ options [ 'class' ] ) ; $ client -> addArgument ( $ argument ) ; $ client -> setPublic ( true ) ; $ client -> setLazy ( $ options [ 'lazy' ] ) ; // set service name based on client name $ serviceName = sprintf ( '%s.client.%s' , $ this -> getAlias ( ) , $ name ) ; $ container -> setDefinition ( $ serviceName , $ client ) ; } }
Loads the Guzzle configuration.

@param array $configs an array of configuration settings
@param \Symfony\Component\DependencyInjection\ContainerBuilder $container a ContainerBuilder instance

@throws \InvalidArgumentException
@throws \Symfony\Component\DependencyInjection\Exception\BadMethodCallException
@throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
@throws \Exception

@return void
Loads the Guzzle configuration .