You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #22779 [4.0][BC Break] Removed BC layers for ControllerResolver::getArguments() (iltar)
This PR was squashed before being merged into the 4.0-dev branch (closes#22779).
Discussion
----------
[4.0][BC Break] Removed BC layers for ControllerResolver::getArguments()
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | no
| New feature? | no
| BC breaks? | yes
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | ~
| License | MIT
| Doc PR | ~
Removes the Backwards Compatibility layer for the `ControllerResolver` that depends on the `ArgumentValueResolver`. ~~There's still 1 bit left in the `HttpKernel`, but I don't quite know how this is solved in the best way:~~
```php
public function __construct(EventDispatcherInterface $dispatcher, ControllerResolverInterface $resolver, RequestStack $requestStack = null, ArgumentResolverInterface $argumentResolver = null)
{
$this->dispatcher = $dispatcher;
$this->resolver = $resolver;
8000
$this->requestStack = $requestStack ?: new RequestStack();
$this->argumentResolver = $argumentResolver;
if (null === $this->argumentResolver) {
@trigger_error(sprintf('As of 3.1 an %s is used to resolve arguments. In 4.0 the $argumentResolver becomes the %s if no other is provided instead of using the $resolver argument.', ArgumentResolverInterface::class, ArgumentResolver::class), E_USER_DEPRECATED);
// fallback in case of deprecations
$this->argumentResolver = $resolver;
}
}
```
~~The 4th argument is now mandatory, but I can't make it mandatory without switching it with the request stack.~~
- ~~I can make both mandatory~~
- ~~I can make it `?RequestStack`~~
- ~~I can switch the arguments~~
~~Each of those area a BC break but for the request stack or the switch, there is no BC layer yet (could be done in 3.4).~~
Commits
-------
64ac6e5 [4.0][BC Break] Removed BC layers for ControllerResolver::getArguments()
@@ -101,71 +82,6 @@ public function getController(Request $request)
101
82
return$callable;
102
83
}
103
84
104
-
/**
105
-
* {@inheritdoc}
106
-
*
107
-
* @deprecated This method is deprecated as of 3.1 and will be removed in 4.0. Implement the ArgumentResolverInterface and inject it in the HttpKernel instead.
@trigger_error(sprintf('%s is deprecated as of 3.1 and will be removed in 4.0. Implement the %s and inject it in the HttpKernel instead.', __METHOD__, ArgumentResolverInterface::class), E_USER_DEPRECATED);
112
-
113
-
if (is_array($controller)) {
114
-
$r = new \ReflectionMethod($controller[0], $controller[1]);
* @return array The arguments to use when calling the action
131
-
*
132
-
* @deprecated This method is deprecated as of 3.1 and will be removed in 4.0. Implement the ArgumentResolverInterface and inject it in the HttpKernel instead.
@trigger_error(sprintf('%s is deprecated as of 3.1 and will be removed in 4.0. Implement the %s and inject it in the HttpKernel instead.', __METHOD__, ArgumentResolverInterface::class), E_USER_DEPRECATED);
137
-
138
-
$attributes = $request->attributes->all();
139
-
$arguments = array();
140
-
foreach ($parametersas$param) {
141
-
if (array_key_exists($param->name, $attributes)) {
142
-
if ($this->supportsVariadic && $param->isVariadic() && is_array($attributes[$param->name])) {
thrownew \RuntimeException(sprintf('Controller "%s" requires that you provide a value for the "$%s" argument (because there is no default value or because there is a non optional argument after this one).', $repr, $param->name));
@trigger_error(sprintf('The %s method is deprecated as of 3.1 and will be removed in 4.0. Please use the %s instead.', __METHOD__, TraceableArgumentResolver::class), E_USER_DEPRECATED);
Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/HttpKernel.php
+1-3Lines changed: 1 addition & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -51,9 +51,7 @@ public function __construct(EventDispatcherInterface $dispatcher, ControllerReso
51
51
$this->argumentResolver = $argumentResolver;
52
52
53
53
if (null === $this->argumentResolver) {
54
-
@trigger_error(sprintf('As of 3.1 an %s is used to resolve arguments. In 4.0 the $argumentResolver becomes the %s if no other is provided instead of using the $resolver argument.', ArgumentResolverInterface::class, ArgumentResolver::class), E_USER_DEPRECATED);
$this->assertEquals(array(), $resolver->getArguments($request, $controller), '->getArguments() returns an empty array if the method takes no arguments');
$this->assertEquals(array('foo'), $resolver->getArguments($request, $controller), '->getArguments() returns an array of arguments for the controller method');
$this->assertEquals(array('foo', null), $resolver->getArguments($request, $controller), '->getArguments() uses default values if present');
167
-
168
-
$request->attributes->set('bar', 'bar');
169
-
$this->assertEquals(array('foo', 'bar'), $resolver->getArguments($request, $controller), '->getArguments() overrides default values if provided in the request attributes');
0 commit comments