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');
$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." 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();
$node = $tree->root('knpu_oauth2_client/clients/' . $key);
$this->buildConfigurationForType($node, $type);
$processor = new Processor();
$config = $processor->process($tree->buildTree(), [$clientConfig]);
$configurator = $this->getConfigurator($type);
// hey, we should add the provider/client service!
$clientServiceKey = $this->configureProviderAndClient($container, $type, $key, $configurator->getProviderClass($config), $configurator->getClientClass($config), $configurator->getPackagistName(), $configurator->getProviderOptions($config), $config['redirect_route'], $config['redirect_params'], $config['use_state']);
$clientServiceKeys[$key] = $clientServiceKey;
}
$container->getDefinition('knpu.oauth2.registry')->replaceArgument(1, $clientServiceKeys);
}