77use Http \Client \Common \Plugin \AuthenticationPlugin ;
88use Http \Client \Common \PluginClient ;
99use Http \Discovery \HttpAsyncClientDiscovery ;
10+ use Http \Discovery \HttpClientDiscovery ;
1011use Http \HttplugBundle \ClientFactory \DummyClient ;
1112use Http \HttplugBundle \Collector \DebugPlugin ;
1213use Http \Message \Authentication \BasicAuth ;
@@ -291,14 +292,22 @@ private function configureAutoDiscoveryClients(ContainerBuilder $container, arra
291292 {
292293 $ httpClient = $ config ['discovery ' ]['client ' ];
293294 if ($ httpClient === 'auto ' ) {
294- $ httpClient = $ this ->registerAutoDiscoverableClientWithDebugPlugin ($ container , 'client ' );
295+ $ httpClient = $ this ->registerAutoDiscoverableClientWithDebugPlugin (
296+ $ container ,
297+ 'client ' ,
298+ [HttpClientDiscovery::class, 'find ' ]
299+ );
295300 } elseif ($ httpClient ) {
296301 $ httpClient = new Reference ($ httpClient );
297302 }
298303
299304 $ asyncHttpClient = $ config ['discovery ' ]['async_client ' ];
300305 if ($ asyncHttpClient === 'auto ' ) {
301- $ asyncHttpClient = $ this ->registerAutoDiscoverableClientWithDebugPlugin ($ container , 'async_client ' );
306+ $ asyncHttpClient = $ this ->registerAutoDiscoverableClientWithDebugPlugin (
307+ $ container ,
308+ 'async_client ' ,
309+ [HttpAsyncClientDiscovery::class, 'find ' ]
310+ );
302311 } elseif ($ asyncHttpClient ) {
303312 $ asyncHttpClient = new Reference ($ httpClient );
304313 }
@@ -310,15 +319,16 @@ private function configureAutoDiscoveryClients(ContainerBuilder $container, arra
310319
311320 /**
312321 * @param ContainerBuilder $container
313- * @param $name
322+ * @param string $name
323+ * @param callable $factory
314324 *
315325 * @return Reference
316326 */
317- private function registerAutoDiscoverableClientWithDebugPlugin (ContainerBuilder $ container , $ name )
327+ private function registerAutoDiscoverableClientWithDebugPlugin (ContainerBuilder $ container , $ name, $ factory )
318328 {
319329 $ definition = $ container ->register ('httplug.auto_discovery_ ' .$ name .'.pure ' , DummyClient::class);
320330 $ definition ->setPublic (false );
321- $ definition ->setFactory ([HttpAsyncClientDiscovery::class, ' find ' ] );
331+ $ definition ->setFactory ($ factory );
322332
323333 $ serviceIdDebugPlugin = $ this ->registerDebugPlugin ($ container , 'auto_discovery_ ' .$ name );
324334 $ container ->register ('httplug.auto_discovery_ ' .$ name .'.plugin ' , PluginClient::class)
0 commit comments