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
-------
3e7a47c0bf
[FrameworkBundle] fix HttpClient integration
This commit is contained in:
commit
4835136e7e
@ -43,8 +43,6 @@ use Symfony\Component\WebLink\HttpHeaderSerializer;
|
||||
*/
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
use HttpClientTrait;
|
||||
|
||||
private $debug;
|
||||
|
||||
/**
|
||||
@ -1332,10 +1330,21 @@ class Configuration implements ConfigurationInterface
|
||||
->beforeNormalization()
|
||||
->always()
|
||||
->then(function ($config) {
|
||||
if (!trait_exists(HttpClientTrait::class)) {
|
||||
throw new LogicException('HttpClient support cannot be enabled as the component is not installed. Try running "composer require symfony/http-client".');
|
||||
}
|
||||
|
||||
$config = \is_array($config) ? $config : ['base_uri' => $config];
|
||||
|
||||
if (!isset($config['scope']) && isset($config['base_uri'])) {
|
||||
$config['scope'] = preg_quote(implode('', self::resolveUrl(self::parseUrl('.'), self::parseUrl($config['base_uri']))));
|
||||
$urlResolver = new class() {
|
||||
use HttpClientTrait {
|
||||
resolveUrl as public;
|
||||
parseUrl as public;
|
||||
}
|
||||
};
|
||||
|
||||
$config['scope'] = preg_quote(implode('', $urlResolver->resolveUrl($urlResolver->parseUrl('.'), $urlResolver->parseUrl($config['base_uri']))));
|
||||
}
|
||||
|
||||
return $config;
|
||||
|
@ -60,7 +60,6 @@ use Symfony\Component\Form\ChoiceList\Factory\CachingFactoryDecorator;
|
||||
use Symfony\Component\Form\FormTypeExtensionInterface;
|
||||
use Symfony\Component\Form\FormTypeGuesserInterface;
|
||||
use Symfony\Component\Form\FormTypeInterface;
|
||||
use Symfony\Component\HttpClient\HttpClient;
|
||||
use Symfony\Component\HttpClient\Psr18Client;
|
||||
use Symfony\Component\HttpClient\ScopingHttpClient;
|
||||
use Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface;
|
||||
@ -1796,10 +1795,6 @@ class FrameworkExtension extends Extension
|
||||
|
||||
private function registerHttpClientConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
|
||||
{
|
||||
if (!class_exists(HttpClient::class)) {
|
||||
throw new LogicException('HttpClient support cannot be enabled as the component is not installed. Try running "composer require symfony/http-client".');
|
||||
}
|
||||
|
||||
$loader->load('http_client.xml');
|
||||
|
||||
$container->getDefinition('http_client')->setArguments([$config['default_options'] ?? [], $config['max_host_connections'] ?? 6]);
|
||||
|
Reference in New Issue
Block a user