|
16 | 16 | use Http\Client\HttpAsyncClient; |
17 | 17 | use Http\Client\Plugin\Vcr\RecordPlugin; |
18 | 18 | use Http\Client\Plugin\Vcr\ReplayPlugin; |
| 19 | +use Http\HttplugBundle\PluginConfigurator; |
19 | 20 | use Http\Message\Authentication\BasicAuth; |
20 | 21 | use Http\Message\Authentication\Bearer; |
21 | 22 | use Http\Message\Authentication\Header; |
22 | 23 | use Http\Message\Authentication\QueryParam; |
23 | 24 | use Http\Message\Authentication\Wsse; |
24 | 25 | use Http\Mock\Client as MockClient; |
| 26 | +use LogicException; |
25 | 27 | use Psr\Http\Client\ClientInterface; |
26 | 28 | use Psr\Http\Message\UriInterface; |
27 | 29 | use Symfony\Component\Config\Definition\ConfigurationInterface; |
@@ -427,6 +429,19 @@ private function configureClient(ContainerBuilder $container, string $clientName |
427 | 429 |
|
428 | 430 | switch ($pluginName) { |
429 | 431 | case 'reference': |
| 432 | + if ($pluginConfig['config'] !== []) { |
| 433 | + if (! is_a($pluginConfig['id'], PluginConfigurator::class, true)) { |
| 434 | + throw new LogicException(sprintf('The plugin "%s" is not a valid PluginConfigurator.', $pluginConfig['id'])); |
| 435 | + } |
| 436 | + |
| 437 | + $config = $pluginConfig['id']::getConfigTreeBuilder()->buildTree()->finalize($pluginConfig['config']); |
| 438 | + |
| 439 | + $definition = new Definition(null, [$config]); |
| 440 | + $definition->setFactory([new Reference($pluginConfig['id']), 'create']); |
| 441 | + |
| 442 | + $plugins[] = $definition; |
| 443 | + break; |
| 444 | + } |
430 | 445 | $plugins[] = new Reference($pluginConfig['id']); |
431 | 446 | break; |
432 | 447 | case 'authentication': |
|
0 commit comments