Skip to content

Commit 3a07636

Browse files
committed
Merge branch '2.8' into 3.0
* 2.8: fix debug toolbar rendering by removing inadvertently added links [Form] minor fix tests of Bootstrap layout [From] minor fix tests added by symfony#17798 for bootstrap theme simplified code Allow variadic controller parameters to be resolved.
2 parents 6c0b229 + 96aaf4f commit 3a07636

File tree

5 files changed

+39
-10
lines changed

5 files changed

+39
-10
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<div class="sf-toolbar-block sf-toolbar-block-{{ name }} sf-toolbar-status-{{ status|default('normal') }} {{ additional_classes|default('') }}">
2-
{% if link|default(true) %}<a href="{{ path('_profiler', { token: token, panel: name }) }}">{% endif %}
2+
{% if link is not defined or link %}<a href="{{ path('_profiler', { token: token, panel: name }) }}">{% endif %}
33
<div class="sf-toolbar-icon">{{ icon|default('') }}</div>
4-
{% if link|default(true) %}</a>{% endif %}
4+
{% if link is not defined or link %}</a>{% endif %}
55
<div class="sf-toolbar-info">{{ text|default('') }}</div>
66
</div>

src/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,7 @@ public function testSingleChoiceExpandedWithLabelsAsFalse()
721721
./input[@type="radio"][@name="name"][@id="name_1"][@value="&b"][not(@checked)]
722722
]
723723
]
724-
/following-sibling::input[@type="hidden"][@id="name__token"][@class="form-control"]
724+
/following-sibling::input[@type="hidden"][@id="name__token"]
725725
]
726726
'
727727
);
@@ -771,7 +771,7 @@ public function testSingleChoiceExpandedWithLabelsSetByCallable()
771771
./input[@type="radio"][@name="name"][@id="name_2"][@value="&c"][not(@checked)]
772772
]
773773
]
774-
/following-sibling::input[@type="hidden"][@id="name__token"][@class="form-control"]
774+
/following-sibling::input[@type="hidden"][@id="name__token"]
775775
]
776776
'
777777
);
@@ -807,7 +807,7 @@ public function testSingleChoiceExpandedWithLabelsSetFalseByCallable()
807807
./input[@type="radio"][@name="name"][@id="name_1"][@value="&b"][not(@checked)]
808808
]
809809
]
810-
/following-sibling::input[@type="hidden"][@id="name__token"][@class="form-control"]
810+
/following-sibling::input[@type="hidden"][@id="name__token"]
811811
]
812812
'
813813
);
@@ -972,7 +972,7 @@ public function testSingleChoiceExpandedWithPlaceholderWithoutTranslation()
972972
./input[@type="radio"][@name="name"][@id="name_1"][not(@checked)]
973973
]
974974
]
975-
/following-sibling::input[@type="hidden"][@id="name__token"][@class="form-control"]
975+
/following-sibling::input[@type="hidden"][@id="name__token"]
976976
]
977977
'
978978
);
@@ -1086,7 +1086,7 @@ public function testMultipleChoiceExpandedWithLabelsAsFalse()
10861086
./input[@type="checkbox"][@name="name[]"][@id="name_1"][@value="&b"][not(@checked)]
10871087
]
10881088
]
1089-
/following-sibling::input[@type="hidden"][@id="name__token"][@class="form-control"]
1089+
/following-sibling::input[@type="hidden"][@id="name__token"]
10901090
]
10911091
'
10921092
);
@@ -1136,7 +1136,7 @@ public function testMultipleChoiceExpandedWithLabelsSetByCallable()
11361136
./input[@type="checkbox"][@name="name[]"][@id="name_2"][@value="&c"][not(@checked)]
11371137
]
11381138
]
1139-
/following-sibling::input[@type="hidden"][@id="name__token"][@class="form-control"]
1139+
/following-sibling::input[@type="hidden"][@id="name__token"]
11401140
]
11411141
'
11421142
);
@@ -1172,7 +1172,7 @@ public function testMultipleChoiceExpandedWithLabelsSetFalseByCallable()
11721172
./input[@type="checkbox"][@name="name[]"][@id="name_1"][@value="&b"][not(@checked)]
11731173
]
11741174
]
1175-
/following-sibling::input[@type="hidden"][@id="name__token"][@class="form-control"]
1175+
/following-sibling::input[@type="hidden"][@id="name__token"]
11761176
]
11771177
'
11781178
);

src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ protected function doGetArguments(Request $request, $controller, array $paramete
105105
$arguments = array();
106106
foreach ($parameters as $param) {
107107
if (array_key_exists($param->name, $attributes)) {
108-
$arguments[] = $attributes[$param->name];
108+
if (PHP_VERSION_ID >= 50600 && $param->isVariadic() && is_array($attributes[$param->name])) {
109+
$arguments = array_merge($arguments, array_values($attributes[$param->name]));
110+
} else {
111+
$arguments[] = $attributes[$param->name];
112+
}
109113
} elseif ($param->getClass() && $param->getClass()->isInstance($request)) {
110114
$arguments[] = $request;
111115
} elseif ($param->isDefaultValueAvailable()) {

src/Symfony/Component/HttpKernel/Tests/Controller/ControllerResolverTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Psr\Log\LoggerInterface;
1515
use Symfony\Component\HttpKernel\Controller\ControllerResolver;
16+
use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\VariadicController;
1617
use Symfony\Component\HttpFoundation\Request;
1718

1819
class ControllerResolverTest extends \PHPUnit_Framework_TestCase
@@ -197,6 +198,20 @@ public function testGetArguments()
197198
$this->assertEquals(array($request), $resolver->getArguments($request, $controller), '->getArguments() injects the request');
198199
}
199200

201+
/**
202+
* @requires PHP 5.6
203+
*/
204+
public function testGetVariadicArguments()
205+
{
206+
$resolver = new ControllerResolver();
207+
208+
$request = Request::create('/');
209+
$request->attributes->set('foo', 'foo');
210+
$request->attributes->set('bar', array('foo', 'bar'));
211+
$controller = array(new VariadicController(), 'action');
212+
$this->assertEquals(array('foo', 'foo', 'bar'), $resolver->getArguments($request, $controller));
213+
}
214+
200215
public function testCreateControllerCanReturnAnyCallable()
201216
{
202217
$mock = $this->getMock('Symfony\Component\HttpKernel\Controller\ControllerResolver', array('createController'));
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Symfony\Component\HttpKernel\Tests\Fixtures\Controller;
4+
5+
class VariadicController
6+
{
7+
public function action($foo, ...$bar)
8+
{
9+
}
10+
}

0 commit comments

Comments
 (0)