8000 bug #30846 [FrameworkBundle] fix HttpClient integration (nicolas-grekas) · symfony/symfony@4835136 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4835136

Browse files
committed
bug #30846 [FrameworkBundle] fix HttpClient integration (nicolas-grekas)
This PR was merged into the 4.3-dev branch. Discussion ---------- [FrameworkBundle] fix HttpClient integration | Q | A | ------------- | --- | Branch? | master | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - HttpClient should be an optional dep. Fixes compat of SecurityBundle 4.2 with FrameworkBundle 4.3 as spotted by the CI. Commits ------- 3e7a47c [FrameworkBundle] fix HttpClient integration
2 parents 99bf6c2 + 3e7a47c commit 4835136

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343
*/
4444
class Configuration implements ConfigurationInterface
4545
{
46-
use HttpClientTrait;
47-
4846
private $debug;
4947

5048
/**
@@ -1332,10 +1330,21 @@ private function addHttpClientSection(ArrayNodeDefinition $rootNode)
13321330 8000
->beforeNormalization()
13331331
->always()
13341332
->then(function ($config) {
1333+
if (!trait_exists(HttpClientTrait::class)) {
1334+
throw new LogicException('HttpClient support cannot be enabled as the component is not installed. Try running "composer require symfony/http-client".');
1335+
}
1336+
13351337
$config = \is_array($config) ? $config : ['base_uri' => $config];
13361338

13371339
if (!isset($config['scope']) && isset($config['base_uri'])) {
1338-
$config['scope'] = preg_quote(implode('', self::resolveUrl(self::parseUrl('.'), self::parseUrl($config['base_uri']))));
1340+
$urlResolver = new class() {
1341+
use HttpClientTrait {
1342+
resolveUrl as public;
1343+
parseUrl as public;
1344+
}
1345+
};
1346+
1347+
$config['scope'] = preg_quote(implode('', $urlResolver->resolveUrl($urlResolver->parseUrl('.'), $urlResolver->parseUrl($config['base_uri']))));
13391348
}
13401349

13411350
return $config;

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
use Symfony\Component\Form\FormTypeExtensionInterface;
6161
use Symfony\Component\Form\FormTypeGuesserInterface;
6262
use Symfony\Component\Form\FormTypeInterface;
63-
use Symfony\Component\HttpClient\HttpClient;
6463
use Symfony\Component\HttpClient\Psr18Client;
6564
use Symfony\Component\HttpClient\ScopingHttpClient;
6665
use Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface;
@@ -1796,10 +1795,6 @@ private function registerCacheConfiguration(array $config, ContainerBuilder $con
17961795

17971796
private function registerHttpClientConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
17981797
{
1799-
if (!class_exists(HttpClient::class)) {
1800-
throw new LogicException('HttpClient support cannot be enabled as the component is not installed. Try running "composer require symfony/http-client".');
1801-
}
1802-
18031798
$loader->load('http_client 435B .xml');
18041799

18051800
$container->getDefinition('http_client')->setArguments([$config['default_options'] ?? [], $config['max_host_connections'] ?? 6]);

0 commit comments

Comments
 (0)
0