Skip to content

Commit 2d61252

Browse files
Merge branch '5.0'
* 5.0: [Mailer] fix typos [Messenger] fix typo [DI] Unknown env prefix not regornized as such [DI] Fix support for multiple tags for locators and iterators [PhpUnitBridge] Fix some errors when using serialized deprecations Fix HTTP client config handling
2 parents ffd25cc + 0330ece commit 2d61252

File tree

5 files changed

+71
-3
lines changed

5 files changed

+71
-3
lines changed

DependencyInjection/Configuration.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,7 @@ private function addHttpClientSection(ArrayNodeDefinition $rootNode)
12791279
if (!\is_array($config)) {
12801280
return [];
12811281
}
1282-
if (!isset($config['host'])) {
1282+
if (!isset($config['host'], $config['value']) || \count($config) > 2) {
12831283
return $config;
12841284
}
12851285

@@ -1388,7 +1388,7 @@ private function addHttpClientSection(ArrayNodeDefinition $rootNode)
13881388
if (!\is_array($config)) {
13891389
return [];
13901390
}
1391-
if (!isset($config['key'])) {
1391+
if (!isset($config['key'], $config['value']) || \count($config) > 2) {
13921392
return $config;
13931393
}
13941394

@@ -1418,7 +1418,7 @@ private function addHttpClientSection(ArrayNodeDefinition $rootNode)
14181418
if (!\is_array($config)) {
14191419
return [];
14201420
}
1421-
if (!isset($config['host'])) {
1421+
if (!isset($config['host'], $config['value']) || \count($config) > 2) {
14221422
return $config;
14231423
}
14241424

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
$container->loadFromExtension('framework', [
4+
'http_client' => [
5+
'default_options' => [
6+
'resolve' => [
7+
'host' => '127.0.0.1',
8+
],
9+
],
10+
'scoped_clients' => [
11+
'foo' => [
12+
'base_uri' => 'http://example.com',
13+
'query' => [
14+
'key' => 'foo',
15+
],
16+
'resolve' => [
17+
'host' => '127.0.0.1',
18+
],
19+
],
20+
],
21+
],
22+
]);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<container xmlns="http://symfony.com/schema/dic/services"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:framework="http://symfony.com/schema/dic/symfony"
5+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
6+
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
7+
8+
<framework:config>
9+
<framework:http-client>
10+
<framework:default-options>
11+
<framework:resolve host="host">127.0.0.1</framework:resolve>
12+
</framework:default-options>
13+
<framework:scoped-client name="foo" base-uri="http://example.com">
14+
<framework:query key="key">foo</framework:query>
15+
<framework:resolve host="host">127.0.0.1</framework:resolve>
16+
</framework:scoped-client>
17+
</framework:http-client>
18+
</framework:config>
19+
</container>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
framework:
2+
http_client:
3+
default_options:
4+
resolve:
5+
host: 127.0.0.1
6+
scoped_clients:
7+
foo:
8+
base_uri: http://example.com
9+
query:
10+
key: foo
11+
resolve:
12+
host: 127.0.0.1

Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,6 +1360,21 @@ public function testHttpClientOverrideDefaultOptions()
13601360
$this->assertSame($expected, $container->getDefinition('foo')->getArgument(2));
13611361
}
13621362

1363+
public function testHttpClientWithQueryParameterKey()
1364+
{
1365+
$container = $this->createContainerFromFile('http_client_xml_key');
1366+
1367+
$expected = [
1368+
'key' => 'foo',
1369+
];
1370+
$this->assertSame($expected, $container->getDefinition('foo')->getArgument(2)['query']);
1371+
1372+
$expected = [
1373+
'host' => '127.0.0.1',
1374+
];
1375+
$this->assertSame($expected, $container->getDefinition('foo')->getArgument(2)['resolve']);
1376+
}
1377+
13631378
public function testHttpClientFullDefaultOptions()
13641379
{
13651380
$container = $this->createContainerFromFile('http_client_full_default_options');

0 commit comments

Comments
 (0)