Skip to content

Commit 8059ece

Browse files
committed
minor #20475 [HttpKernel] [MapQueryString] Add docs for new key option (feymo)
This PR was merged into the 7.3 branch. Discussion ---------- [HttpKernel] [MapQueryString] Add docs for new key option Will fix #20463 Add documentation for the new `key` option added to `MapQueryString` attribute added in symfony/symfony#59157 Commits ------- 2fdd0db docs(controller): add docs for key option in MapQueryString
2 parents 7586784 + 2fdd0db commit 8059ece

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

controller.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,27 @@ HTTP status to return if the validation fails::
443443

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

446+
If you want to map your object to a nested array in your query with a specific key,
447+
you can use the ``key`` option in your :class:`Symfony\\Component\\HttpKernel\\Attribute\\MapQueryString`
448+
attribute::
449+
450+
use App\Model\SearchDto;
451+
use Symfony\Component\HttpFoundation\Response;
452+
use Symfony\Component\HttpKernel\Attribute\MapQueryString;
453+
454+
// ...
455+
456+
public function dashboard(
457+
#[MapQueryString(key: 'search')] SearchDto $searchDto
458+
): Response
459+
{
460+
// ...
461+
}
462+
463+
.. versionadded:: 7.3
464+
465+
The ``key`` option of ``#[MapQueryString]`` was introduced in Symfony 7.3.
466+
446467
If you need a valid DTO even when the request query string is empty, set a
447468
default value for your controller arguments::
448469

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy