public function load(array $configs, ContainerBuilder $container)
    {
        $processor = new Processor();
        $configuration = new Configuration();
        $config = $processor->processConfiguration($configuration, $configs);

        $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
        $loader->load('services.xml');

        $httpClient = $config['http_client'];
        $httpClientOptions = $config['http_client_options'];
        $clientConfigurations = $config['clients'];

        $clientServiceKeys = [];
        foreach ($clientConfigurations as $key => $clientConfig) {
            // manually make sure "type" is there
            if (!isset($clientConfig['type'])) {
                throw new InvalidConfigurationException(sprintf(
                    'Your "knpu_oauth2_client.clients.%s" config entry is missing the "type" key.',
                    $key
                ));
            }

            $type = $clientConfig['type'];
            unset($clientConfig['type']);
            if (!isset(self::$supportedProviderTypes[$type])) {
                throw new InvalidConfigurationException(sprintf(
                    'The "knpu_oauth2_client.clients" config "type" key "%s" is not supported. We support (%s)',
                    $type,
                    implode(', ', self::$supportedProviderTypes)
                ));
            }

            // process the configuration
            $tree = new TreeBuilder('knpu_oauth2_client/clients/' . $key);
            $node = method_exists($tree, 'getRootNode')
                ? $tree->getRootNode()
                : $tree->root('knpu_oauth2_client/clients/' . $key);

            $this->buildConfigurationForType($node, $type);
            $processor = new Processor();
            $config = $processor->process($tree->buildTree(), [$clientConfig]);

            $configurator = $this->getConfigurator($type);

            $providerOptions = $configurator->getProviderOptions($config);

            $collaborators = [];
            if ($httpClient) {
                $collaborators['httpClient'] = new Reference($httpClient);
            } else {
                $providerOptions = array_merge($providerOptions, $httpClientOptions);
            }
            // hey, we should add the provider/client service!
            $clientServiceKey = $this->configureProviderAndClient(
                $container,
                $type,
                $key,
                $configurator->getProviderClass($config),
                $configurator->getClientClass($config),
                $configurator->getPackagistName(),
                $providerOptions,
                $config['redirect_route'],
                $config['redirect_params'],
                $config['use_state'],
                $collaborators
            );

            $clientServiceKeys[$key] = $clientServiceKey;
        }

        $container->getDefinition('knpu.oauth2.registry')
            ->replaceArgument(1, $clientServiceKeys);
    }
public function load(array $configs, ContainerBuilder $container)
    {
        $processor = new Processor();
        $configuration = new Configuration();
        $config = $processor->processConfiguration($configuration, $configs);

        $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
        $loader->load('services.xml');

        $httpClient = $config['http_client'];
        $httpClientOptions = $config['http_client_options'];
        $clientConfigurations = $config['clients'];

        $clientServiceKeys = [];
        foreach ($clientConfigurations as $key => $clientConfig) {
            // manually make sure "type" is there
            if (!isset($clientConfig['type'])) {
                throw new InvalidConfigurationException(sprintf(
                    'Your "knpu_oauth2_client.clients.%s" config entry is missing the "type" key.',
                    $key
                ));
            }

            $type = $clientConfig['type'];
            unset($clientConfig['type']);
            if (!isset(self::$supportedProviderTypes[$type])) {
                throw new InvalidConfigurationException(sprintf(
                    'The "knpu_oauth2_client.clients" config "type" key "%s" is not supported. We support (%s)',
                    $type,
                    implode(', ', self::$supportedProviderTypes)
                ));
            }

            // process the configuration
            $tree = new TreeBuilder('knpu_oauth2_client/clients/' . $key);
            $node = method_exists($tree, 'getRootNode')
                ? $tree->getRootNode()
                : $tree->root('knpu_oauth2_client/clients/' . $key);

            $this->buildConfigurationForType($node, $type);
            $processor = new Processor();
            $config = $processor->process($tree->buildTree(), [$clientConfig]);

            $configurator = $this->getConfigurator($type);

            $providerOptions = $configurator->getProviderOptions($config);

            $collaborators = [];
            if ($httpClient) {
                $collaborators['httpClient'] = new Reference($httpClient);
            } else {
                $providerOptions = array_merge($providerOptions, $httpClientOptions);
            }
            // hey, we should add the provider/client service!
            $clientServiceKey = $this->configureProviderAndClient(
                $container,
                $type,
                $key,
                $configurator->getProviderClass($config),
                $configurator->getClientClass($config),
                $configurator->getPackagistName(),
                $providerOptions,
                $config['redirect_route'],
                $config['redirect_params'],
                $config['use_state'],
                $collaborators
            );

            $clientServiceKeys[$key] = $clientServiceKey;
        }

        $container->getDefinition('knpu.oauth2.registry')
            ->replaceArgument(1, $clientServiceKeys);
    }
public function load ( array $ configs , ContainerBuilder $ container ) { $ processor = new Processor ( ) ; $ configuration = new Configuration ( ) ; $ config = $ processor -> processConfiguration ( $ configuration , $ configs ) ; $ loader = new XmlFileLoader ( $ container , new FileLocator ( __DIR__ . '/../Resources/config' ) ) ; $ loader -> load ( 'services.xml' ) ; $ httpClient = $ config [ 'http_client' ] ; $ httpClientOptions = $ config [ 'http_client_options' ] ; $ clientConfigurations = $ config [ 'clients' ] ; $ clientServiceKeys = [ ] ; foreach ( $ clientConfigurations as $ key => $ clientConfig ) { // manually make sure "type" is there if ( ! isset ( $ clientConfig [ 'type' ] ) ) { throw new InvalidConfigurationException ( sprintf ( 'Your "knpu_oauth2_client.clients.%s" config entry is missing the "type" key.' , $ key ) ) ; } $ type = $ clientConfig [ 'type' ] ; unset ( $ clientConfig [ 'type' ] ) ; if ( ! isset ( self :: $ supportedProviderTypes [ $ type ] ) ) { throw new InvalidConfigurationException ( sprintf ( 'The "knpu_oauth2_client.clients" config "type" key "%s" is not supported. We support (%s)' , $ type , implode ( ', ' , self :: $ supportedProviderTypes ) ) ) ; } // process the configuration $ tree = new TreeBuilder ( 'knpu_oauth2_client/clients/' . $ key ) ; $ node = method_exists ( $ tree , 'getRootNode' ) ? $ tree -> getRootNode ( ) : $ tree -> root ( 'knpu_oauth2_client/clients/' . $ key ) ; $ this -> buildConfigurationForType ( $ node , $ type ) ; $ processor = new Processor ( ) ; $ config = $ processor -> process ( $ tree -> buildTree ( ) , [ $ clientConfig ] ) ; $ configurator = $ this -> getConfigurator ( $ type ) ; $ providerOptions = $ configurator -> getProviderOptions ( $ config ) ; $ collaborators = [ ] ; if ( $ httpClient ) { $ collaborators [ 'httpClient' ] = new Reference ( $ httpClient ) ; } else { $ providerOptions = array_merge ( $ providerOptions , $ httpClientOptions ) ; } // hey, we should add the provider/client service! $ clientServiceKey = $ this -> configureProviderAndClient ( $ container , $ type , $ key , $ configurator -> getProviderClass ( $ config ) , $ configurator -> getClientClass ( $ config ) , $ configurator -> getPackagistName ( ) , $ providerOptions , $ config [ 'redirect_route' ] , $ config [ 'redirect_params' ] , $ config [ 'use_state' ] , $ collaborators ) ; $ clientServiceKeys [ $ key ] = $ clientServiceKey ; } $ container -> getDefinition ( 'knpu.oauth2.registry' ) -> replaceArgument ( 1 , $ clientServiceKeys ) ; }
Load the bundle configuration.

@param array $configs
@param ContainerBuilder $container
Load the bundle configuration .