13
13
14
14
use Doctrine \Common \Annotations \AnnotationRegistry ;
15
15
use Doctrine \Common \Annotations \Reader ;
16
+ use Http \Client \HttpClient ;
16
17
use Psr \Cache \CacheItemPoolInterface ;
17
18
use Psr \Container \ContainerInterface as PsrContainerInterface ;
18
19
use Psr \Http \Client \ClientInterface ;
60
61
use Symfony \Component \Form \FormTypeExtensionInterface ;
61
62
use Symfony \Component \Form \FormTypeGuesserInterface ;
62
63
use Symfony \Component \Form \FormTypeInterface ;
63
- use Symfony \Component \HttpClient \Psr18Client ;
64
64
use Symfony \Component \HttpClient \ScopingHttpClient ;
65
65
use Symfony \Component \HttpKernel \CacheClearer \CacheClearerInterface ;
66
66
use Symfony \Component \HttpKernel \CacheWarmer \CacheWarmerInterface ;
@@ -1881,6 +1881,11 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder
1881
1881
$ container ->removeAlias (ClientInterface::class);
1882
1882
}
1883
1883
1884
+ if (!interface_exists (HttpClient::class)) {
1885
+ $ container ->removeDefinition ('plug.http_client ' );
1886
+ $ container ->removeAlias (HttpClient::class);
1887
+ }
1888
+
1884
1889
foreach ($ config ['scoped_clients ' ] as $ name => $ scopeConfig ) {
1885
1890
if ('http_client ' === $ name ) {
1886
1891
throw new InvalidArgumentException (sprintf ('Invalid scope name: "%s" is reserved. ' , $ name ));
@@ -1901,9 +1906,8 @@ private function registerHttpClientConfiguration(array $config, ContainerBuilder
1901
1906
$ container ->registerAliasForArgument ($ name , HttpClientInterface::class);
1902
1907
1903
1908
if ($ hasPsr18 ) {
1904
- $ container ->register ('psr18. ' .$ name , Psr18Client::class)
1905
- ->setAutowired (true )
1906
- ->setArguments ([new Reference ($ name )]);
1909
+ $ container ->setDefinition ('psr18. ' .$ name , new ChildDefinition ('psr18.http_client ' ))
1910
+ ->replaceArgument (0 , new Reference ($ name ));
1907
1911
1908
1912
$ container ->registerAliasForArgument ('psr18. ' .$ name , ClientInterface::class, $ name );
1909
1913
}
0 commit comments