7
7
use Http \Client \Common \Plugin \AuthenticationPlugin ;
8
8
use Http \Client \Common \PluginClient ;
9
9
use Http \Discovery \HttpAsyncClientDiscovery ;
10
+ use Http \Discovery \HttpClientDiscovery ;
10
11
use Http \HttplugBundle \ClientFactory \DummyClient ;
11
12
use Http \HttplugBundle \Collector \DebugPlugin ;
12
13
use Http \Message \Authentication \BasicAuth ;
@@ -291,14 +292,22 @@ private function configureAutoDiscoveryClients(ContainerBuilder $container, arra
291
292
{
292
293
$ httpClient = $ config ['discovery ' ]['client ' ];
293
294
if ($ httpClient === 'auto ' ) {
294
- $ httpClient = $ this ->registerAutoDiscoverableClientWithDebugPlugin ($ container , 'client ' );
295
+ $ httpClient = $ this ->registerAutoDiscoverableClientWithDebugPlugin (
296
+ $ container ,
297
+ 'client ' ,
298
+ [HttpClientDiscovery::class, 'find ' ]
299
+ );
295
300
} elseif ($ httpClient ) {
296
301
$ httpClient = new Reference ($ httpClient );
297
302
}
298
303
299
304
$ asyncHttpClient = $ config ['discovery ' ]['async_client ' ];
300
305
if ($ asyncHttpClient === 'auto ' ) {
301
- $ asyncHttpClient = $ this ->registerAutoDiscoverableClientWithDebugPlugin ($ container , 'async_client ' );
306
+ $ asyncHttpClient = $ this ->registerAutoDiscoverableClientWithDebugPlugin (
307
+ $ container ,
308
+ 'async_client ' ,
309
+ [HttpAsyncClientDiscovery::class, 'find ' ]
310
+ );
302
311
} elseif ($ asyncHttpClient ) {
303
312
$ asyncHttpClient = new Reference ($ httpClient );
304
313
}
@@ -310,15 +319,16 @@ private function configureAutoDiscoveryClients(ContainerBuilder $container, arra
310
319
311
320
/**
312
321
* @param ContainerBuilder $container
313
- * @param $name
322
+ * @param string $name
323
+ * @param callable $factory
314
324
*
315
325
* @return Reference
316
326
*/
317
- private function registerAutoDiscoverableClientWithDebugPlugin (ContainerBuilder $ container , $ name )
327
+ private function registerAutoDiscoverableClientWithDebugPlugin (ContainerBuilder $ container , $ name, $ factory )
318
328
{
319
329
$ definition = $ container ->register ('httplug.auto_discovery_ ' .$ name .'.pure ' , DummyClient::class);
320
330
$ definition ->setPublic (false );
321
- $ definition ->setFactory ([HttpAsyncClientDiscovery::class, ' find ' ] );
331
+ $ definition ->setFactory ($ factory );
322
332
323
333
$ serviceIdDebugPlugin = $ this ->registerDebugPlugin ($ container , 'auto_discovery_ ' .$ name );
324
334
$ container ->register ('httplug.auto_discovery_ ' .$ name .'.plugin ' , PluginClient::class)
0 commit comments