[FrameworkBundle] fix HttpClient integration
This commit is contained in:
parent
bce6124f8f
commit
3e7a47c0bf
@ -43,8 +43,6 @@ use Symfony\Component\WebLink\HttpHeaderSerializer;
|
|||||||
*/
|
*/
|
||||||
class Configuration implements ConfigurationInterface
|
class Configuration implements ConfigurationInterface
|
||||||
{
|
{
|
||||||
use HttpClientTrait;
|
|
||||||
|
|
||||||
private $debug;
|
private $debug;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1332,10 +1330,21 @@ class Configuration implements ConfigurationInterface
|
|||||||
->beforeNormalization()
|
->beforeNormalization()
|
||||||
->always()
|
->always()
|
||||||
->then(function ($config) {
|
->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];
|
$config = \is_array($config) ? $config : ['base_uri' => $config];
|
||||||
|
|
||||||
if (!isset($config['scope']) && isset($config['base_uri'])) {
|
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;
|
return $config;
|
||||||
|
@ -60,7 +60,6 @@ use Symfony\Component\Form\ChoiceList\Factory\CachingFactoryDecorator;
|
|||||||
use Symfony\Component\Form\FormTypeExtensionInterface;
|
use Symfony\Component\Form\FormTypeExtensionInterface;
|
||||||
use Symfony\Component\Form\FormTypeGuesserInterface;
|
use Symfony\Component\Form\FormTypeGuesserInterface;
|
||||||
use Symfony\Component\Form\FormTypeInterface;
|
use Symfony\Component\Form\FormTypeInterface;
|
||||||
use Symfony\Component\HttpClient\HttpClient;
|
|
||||||
use Symfony\Component\HttpClient\Psr18Client;
|
use Symfony\Component\HttpClient\Psr18Client;
|
||||||
use Symfony\Component\HttpClient\ScopingHttpClient;
|
use Symfony\Component\HttpClient\ScopingHttpClient;
|
||||||
use Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface;
|
use Symfony\Component\HttpKernel\CacheClearer\CacheClearerInterface;
|
||||||
@ -1796,10 +1795,6 @@ class FrameworkExtension extends Extension
|
|||||||
|
|
||||||
private function registerHttpClientConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
|
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');
|
$loader->load('http_client.xml');
|
||||||
|
|
||||||
$container->getDefinition('http_client')->setArguments([$config['default_options'] ?? [], $config['max_host_connections'] ?? 6]);
|
$container->getDefinition('http_client')->setArguments([$config['default_options'] ?? [], $config['max_host_connections'] ?? 6]);
|
||||||
|
Reference in New Issue
Block a user