Merge branch '3.0'
* 3.0: fix debug toolbar rendering by removing inadvertently added links [Form] minor fix tests of Bootstrap layout [From] minor fix tests added by #17798 for bootstrap theme simplified code Allow variadic controller parameters to be resolved.
This commit is contained in:
commit
11e1aa8d7c
@ -1,5 +1,5 @@
|
||||
<div class="sf-toolbar-block sf-toolbar-block-{{ name }} sf-toolbar-status-{{ status|default('normal') }} {{ additional_classes|default('') }}">
|
||||
{% if link|default(false) %}<a href="{{ path('_profiler', { token: token, panel: name }) }}">{% endif %}
|
||||
{% if link is not defined or link %}<a href="{{ path('_profiler', { token: token, panel: name }) }}">{% endif %}
|
||||
<div class="sf-toolbar-icon">{{ icon|default('') }}</div>
|
||||
{% if link|default(false) %}</a>{% endif %}
|
||||
<div class="sf-toolbar-info">{{ text|default('') }}</div>
|
||||
|
@ -721,7 +721,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
./input[@type="radio"][@name="name"][@id="name_1"][@value="&b"][not(@checked)]
|
||||
]
|
||||
]
|
||||
/following-sibling::input[@type="hidden"][@id="name__token"][@class="form-control"]
|
||||
/following-sibling::input[@type="hidden"][@id="name__token"]
|
||||
]
|
||||
'
|
||||
);
|
||||
@ -771,7 +771,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
./input[@type="radio"][@name="name"][@id="name_2"][@value="&c"][not(@checked)]
|
||||
]
|
||||
]
|
||||
/following-sibling::input[@type="hidden"][@id="name__token"][@class="form-control"]
|
||||
/following-sibling::input[@type="hidden"][@id="name__token"]
|
||||
]
|
||||
'
|
||||
);
|
||||
@ -807,7 +807,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
./input[@type="radio"][@name="name"][@id="name_1"][@value="&b"][not(@checked)]
|
||||
]
|
||||
]
|
||||
/following-sibling::input[@type="hidden"][@id="name__token"][@class="form-control"]
|
||||
/following-sibling::input[@type="hidden"][@id="name__token"]
|
||||
]
|
||||
'
|
||||
);
|
||||
@ -972,7 +972,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
./input[@type="radio"][@name="name"][@id="name_1"][not(@checked)]
|
||||
]
|
||||
]
|
||||
/following-sibling::input[@type="hidden"][@id="name__token"][@class="form-control"]
|
||||
/following-sibling::input[@type="hidden"][@id="name__token"]
|
||||
]
|
||||
'
|
||||
);
|
||||
@ -1086,7 +1086,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
./input[@type="checkbox"][@name="name[]"][@id="name_1"][@value="&b"][not(@checked)]
|
||||
]
|
||||
]
|
||||
/following-sibling::input[@type="hidden"][@id="name__token"][@class="form-control"]
|
||||
/following-sibling::input[@type="hidden"][@id="name__token"]
|
||||
]
|
||||
'
|
||||
);
|
||||
@ -1136,7 +1136,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
./input[@type="checkbox"][@name="name[]"][@id="name_2"][@value="&c"][not(@checked)]
|
||||
]
|
||||
]
|
||||
/following-sibling::input[@type="hidden"][@id="name__token"][@class="form-control"]
|
||||
/following-sibling::input[@type="hidden"][@id="name__token"]
|
||||
]
|
||||
'
|
||||
);
|
||||
@ -1172,7 +1172,7 @@ abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest
|
||||
./input[@type="checkbox"][@name="name[]"][@id="name_1"][@value="&b"][not(@checked)]
|
||||
]
|
||||
]
|
||||
/following-sibling::input[@type="hidden"][@id="name__token"][@class="form-control"]
|
||||
/following-sibling::input[@type="hidden"][@id="name__token"]
|
||||
]
|
||||
'
|
||||
);
|
||||
|
@ -105,7 +105,11 @@ class ControllerResolver implements ControllerResolverInterface
|
||||
$arguments = array();
|
||||
foreach ($parameters as $param) {
|
||||
if (array_key_exists($param->name, $attributes)) {
|
||||
$arguments[] = $attributes[$param->name];
|
||||
if (PHP_VERSION_ID >= 50600 && $param->isVariadic() && is_array($attributes[$param->name])) {
|
||||
$arguments = array_merge($arguments, array_values($attributes[$param->name]));
|
||||
} else {
|
||||
$arguments[] = $attributes[$param->name];
|
||||
}
|
||||
} elseif ($param->getClass() && $param->getClass()->isInstance($request)) {
|
||||
$arguments[] = $request;
|
||||
} elseif ($param->isDefaultValueAvailable()) {
|
||||
|
@ -13,6 +13,7 @@ namespace Symfony\Component\HttpKernel\Tests\Controller;
|
||||
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\HttpKernel\Controller\ControllerResolver;
|
||||
use Symfony\Component\HttpKernel\Tests\Fixtures\Controller\VariadicController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
class ControllerResolverTest extends \PHPUnit_Framework_TestCase
|
||||
@ -197,6 +198,20 @@ class ControllerResolverTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(array($request), $resolver->getArguments($request, $controller), '->getArguments() injects the request');
|
||||
}
|
||||
|
||||
/**
|
||||
* @requires PHP 5.6
|
||||
*/
|
||||
public function testGetVariadicArguments()
|
||||
{
|
||||
$resolver = new ControllerResolver();
|
||||
|
||||
$request = Request::create('/');
|
||||
$request->attributes->set('foo', 'foo');
|
||||
$request->attributes->set('bar', array('foo', 'bar'));
|
||||
$controller = array(new VariadicController(), 'action');
|
||||
$this->assertEquals(array('foo', 'foo', 'bar'), $resolver->getArguments($request, $controller));
|
||||
}
|
||||
|
||||
public function testCreateControllerCanReturnAnyCallable()
|
||||
{
|
||||
$mock = $this->getMock('Symfony\Component\HttpKernel\Controller\ControllerResolver', array('createController'));
|
||||
|
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Component\HttpKernel\Tests\Fixtures\Controller;
|
||||
|
||||
class VariadicController
|
||||
{
|
||||
public function action($foo, ...$bar)
|
||||
{
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user