@@ -150,6 +150,7 @@ class FrameworkExtension extends Extension
150150 private $ validatorConfigEnabled = false ;
151151 private $ messengerConfigEnabled = false ;
152152 private $ mailerConfigEnabled = false ;
153+ private $ httpClientConfigEnabled = false ;
153154
154155 /**
155156 * Responds to the app.config configuration parameter.
@@ -311,6 +312,10 @@ public function load(array $configs, ContainerBuilder $container)
311312 $ container ->removeDefinition ('console.command.messenger_failed_messages_remove ' );
312313 }
313314
315+ if ($ this ->httpClientConfigEnabled = $ this ->isConfigEnabled ($ container , $ config ['http_client ' ])) {
316+ $ this ->registerHttpClientConfiguration ($ config ['http_client ' ], $ container , $ loader , $ config ['profiler ' ]);
317+ }
318+
314319 $ propertyInfoEnabled = $ this ->isConfigEnabled ($ container , $ config ['property_info ' ]);
315320 $ this ->registerValidationConfiguration ($ config ['validation ' ], $ container , $ loader , $ propertyInfoEnabled );
316321 $ this ->registerEsiConfiguration ($ config ['esi ' ], $ container , $ loader );
@@ -341,10 +346,6 @@ public function load(array $configs, ContainerBuilder $container)
341346 $ this ->registerLockConfiguration ($ config ['lock ' ], $ container , $ loader );
342347 }
343348
344- if ($ this ->isConfigEnabled ($ container , $ config ['http_client ' ])) {
345- $ this ->registerHttpClientConfiguration ($ config ['http_client ' ], $ container , $ loader );
346- }
347-
348349 if ($ this ->mailerConfigEnabled = $ this ->isConfigEnabled ($ container , $ config ['mailer ' ])) {
349350 $ this ->registerMailerConfiguration ($ config ['mailer ' ], $ container , $ loader );
350351 }
@@ -562,6 +563,10 @@ private function registerProfilerConfiguration(array $config, ContainerBuilder $
562563 $ loader ->load ('mailer_debug.xml ' );
563564 }
564565
566+ if ($ this ->httpClientConfigEnabled ) {
567+ $ loader ->load ('http_client_debug.xml ' );
568+ }
569+
565570 $ container ->setParameter ('profiler_listener.only_exceptions ' , $ config ['only_exceptions ' ]);
566571 $ container ->setParameter ('profiler_listener.only_master_requests ' , $ config ['only_master_requests ' ]);
567572
@@ -1915,7 +1920,7 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con
19151920 }
19161921 }
19171922
1918- private function registerHttpClientConfiguration (array $ config , ContainerBuilder $ container , XmlFileLoader $ loader )
1923+ private function registerHttpClientConfiguration (array $ config , ContainerBuilder $ container , XmlFileLoader $ loader, array $ profilerConfig )
19191924 {
19201925 $ loader ->load ('http_client.xml ' );
19211926
@@ -1930,6 +1935,8 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder
19301935 $ container ->removeDefinition (HttpClient::class);
19311936 }
19321937
1938+ $ httpClientId = $ this ->isConfigEnabled ($ container , $ profilerConfig ) ? '.debug.http_client.inner ' : 'http_client ' ;
1939+
19331940 foreach ($ config ['scoped_clients ' ] as $ name => $ scopeConfig ) {
19341941 if ('http_client ' === $ name ) {
19351942 throw new InvalidArgumentException (sprintf ('Invalid scope name: "%s" is reserved. ' , $ name ));
@@ -1941,10 +1948,14 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder
19411948 if (null === $ scope ) {
19421949 $ container ->register ($ name , ScopingHttpClient::class)
19431950 ->setFactory ([ScopingHttpClient::class, 'forBaseUri ' ])
1944- ->setArguments ([new Reference ('http_client ' ), $ scopeConfig ['base_uri ' ], $ scopeConfig ]);
1951+ ->setArguments ([new Reference ($ httpClientId ), $ scopeConfig ['base_uri ' ], $ scopeConfig ])
1952+ ->addTag ('http_client.client ' )
1953+ ;
19451954 } else {
19461955 $ container ->register ($ name , ScopingHttpClient::class)
1947- ->setArguments ([new Reference ('http_client ' ), [$ scope => $ scopeConfig ], $ scope ]);
1956+ ->setArguments ([new Reference ($ httpClientId ), [$ scope => $ scopeConfig ], $ scope ])
1957+ ->addTag ('http_client.client ' )
1958+ ;
19481959 }
19491960
19501961 $ container ->registerAliasForArgument ($ name , HttpClientInterface::class);
0 commit comments