@@ -150,6 +150,7 @@ class FrameworkExtension extends Extension
150
150
private $ validatorConfigEnabled = false ;
151
151
private $ messengerConfigEnabled = false ;
152
152
private $ mailerConfigEnabled = false ;
153
+ private $ httpClientConfigEnabled = false ;
153
154
154
155
/**
155
156
* Responds to the app.config configuration parameter.
@@ -311,6 +312,10 @@ public function load(array $configs, ContainerBuilder $container)
311
312
$ container ->removeDefinition ('console.command.messenger_failed_messages_remove ' );
312
313
}
313
314
315
+ if ($ this ->httpClientConfigEnabled = $ this ->isConfigEnabled ($ container , $ config ['http_client ' ])) {
316
+ $ this ->registerHttpClientConfiguration ($ config ['http_client ' ], $ container , $ loader , $ config ['profiler ' ]);
317
+ }
318
+
314
319
$ propertyInfoEnabled = $ this ->isConfigEnabled ($ container , $ config ['property_info ' ]);
315
320
$ this ->registerValidationConfiguration ($ config ['validation ' ], $ container , $ loader , $ propertyInfoEnabled );
316
321
$ this ->registerEsiConfiguration ($ config ['esi ' ], $ container , $ loader );
@@ -341,10 +346,6 @@ public function load(array $configs, ContainerBuilder $container)
341
346
$ this ->registerLockConfiguration ($ config ['lock ' ], $ container , $ loader );
342
347
}
343
348
344
- if ($ this ->isConfigEnabled ($ container , $ config ['http_client ' ])) {
345
- $ this ->registerHttpClientConfiguration ($ config ['http_client ' ], $ container , $ loader );
346
- }
347
-
348
349
if ($ this ->mailerConfigEnabled = $ this ->isConfigEnabled ($ container , $ config ['mailer ' ])) {
349
350
$ this ->registerMailerConfiguration ($ config ['mailer ' ], $ container , $ loader );
350
351
}
@@ -562,6 +563,10 @@ private function registerProfilerConfiguration(array $config, ContainerBuilder $
562
563
$ loader ->load ('mailer_debug.xml ' );
563
564
}
564
565
566
+ if ($ this ->httpClientConfigEnabled ) {
567
+ $ loader ->load ('http_client_debug.xml ' );
568
+ }
569
+
565
570
$ container ->setParameter ('profiler_listener.only_exceptions ' , $ config ['only_exceptions ' ]);
566
571
$ container ->setParameter ('profiler_listener.only_master_requests ' , $ config ['only_master_requests ' ]);
567
572
@@ -1915,7 +1920,7 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con
1915
1920
}
1916
1921
}
1917
1922
1918
- private function registerHttpClientConfiguration (array $ config , ContainerBuilder $ container , XmlFileLoader $ loader )
1923
+ private function registerHttpClientConfiguration (array $ config , ContainerBuilder $ container , XmlFileLoader $ loader, array $ profilerConfig )
1919
1924
{
1920
1925
$ loader ->load ('http_client.xml ' );
1921
1926
@@ -1930,6 +1935,8 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder
1930
1935
$ container ->removeDefinition (HttpClient::class);
1931
1936
}
1932
1937
1938
+ $ httpClientId = $ this ->isConfigEnabled ($ container , $ profilerConfig ) ? '.debug.http_client.inner ' : 'http_client ' ;
1939
+
1933
1940
foreach ($ config ['scoped_clients ' ] as $ name => $ scopeConfig ) {
1934
1941
if ('http_client ' === $ name ) {
1935
1942
throw new InvalidArgumentException (sprintf ('Invalid scope name: "%s" is reserved. ' , $ name ));
@@ -1941,10 +1948,14 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder
1941
1948
if (null === $ scope ) {
1942
1949
$ container ->register ($ name , ScopingHttpClient::class)
1943
1950
->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
+ ;
1945
1954
} else {
1946
1955
$ 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
+ ;
1948
1959
}
1949
1960
1950
1961
$ container ->registerAliasForArgument ($ name , HttpClientInterface::class);
0 commit comments