Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit02a2e4d

Browse files
committed
Merge branch '7.0' into 7.1
* 7.0: [HttpKernel] Explain how to define default value in MapQueryString
2 parents6ffabcc +e9a379e commit02a2e4d

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

‎controller.rst‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,22 @@ HTTP status to return if the validation fails::
442442

443443
The default status code returned if the validation fails is 404.
444444

445+
If you need a valid DTO even when the request query string is empty, set a
446+
default value for your controller arguments::
447+
448+
use App\Model\UserDto;
449+
use Symfony\Component\HttpFoundation\Response;
450+
use Symfony\Component\HttpKernel\Attribute\MapQueryString;
451+
452+
// ...
453+
454+
public function dashboard(
455+
#[MapQueryString] UserDTO $userDto = new UserDTO()
456+
): Response
457+
{
458+
// ...
459+
}
460+
445461
.. _controller-mapping-request-payload:
446462

447463
Mapping Request Payload

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp