-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[HttpFoundation] Add InputBag #13543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
We should take care of this as soon as possible. We're getting some issues from people who is confused about this: symfony/symfony#37029, symfony/symfony#36725, symfony/symfony#37229, etc. @azjezz explained to me that this is how the new code works: // new method -> equivalent code
get('foo') is getString('foo')
all('foo') is getArray('foo')
all() is getAll()
all()['foo'] ?? null is getStringOrArrayOrNull('foo') Any volunteer to provide these docs? |
Some more information: The problem solved by InputBag is that when the URL is Thanks to InputBag this now shows a deprecation, but in Symfony 6 it will generate the expected 400 error. |
To explain more, the 500 error doesn't result from e.g: class FooRepository
{
// code ..
/**
* Search for all the foos containing the given keyword.
*/
public function search(string $keyword): iterable
{
}
// code ...
} final class FooController extends AbstractController
{
private FooRepository $foos;
public function __construct(FooRepository $foos)
{
$this->foos = $foos;
}
/**
* @Route('/foo/search', methods={'GET'}, name='foo_search')
*/
public function search(Request $request): Response
{
$keyword = $request->request->get('q', null);
if (null === $keyword) {
$foos = [];
} else {
$foos = $this->foos->search($keyword);
}
// render foos
}
} in the example above, the expected value for
if you are expecting this array, use |
Note: |
Thank you for this issue. |
Friendly reminder that this issue exists. If I don't hear anything I'll close this. |
Hey, I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen! |
The text was updated successfully, but these errors were encountered: