Skip to content

Commit 8bb1c1c

Browse files
committed
Merge branch '6.3' into 6.4
* 6.3: Update error_pages.rst [HttpKernel] Add customization options to `#[MapQueryString]` and `#[MapRequestPayload]`
2 parents 3a9a287 + d1f2c14 commit 8bb1c1c

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

controller.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,16 @@ attribute in your controller::
430430
// ...
431431
}
432432

433+
You can customize the validation groups used during the mapping thanks to the
434+
``validationGroups`` option::
435+
436+
public function dashboard(
437+
#[MapQueryString(validationGroups: ['strict', 'edit'])] UserDTO $userDto
438+
): Response
439+
{
440+
// ...
441+
}
442+
433443
.. versionadded:: 6.3
434444

435445
The :class:`Symfony\\Component\\HttpKernel\\Attribute\\MapQueryString` attribute
@@ -482,6 +492,16 @@ your DTO::
482492
// ...
483493
}
484494

495+
You can also customize the validation groups used as well as supported
496+
payload formats::
497+
498+
public function dashboard(
499+
#[MapRequestPayload(acceptFormat: 'json', validationGroups: ['strict', 'read'])] UserDTO $userDto
500+
): Response
501+
{
502+
// ...
503+
}
504+
485505
.. versionadded:: 6.3
486506

487507
The :class:`Symfony\\Component\\HttpKernel\\Attribute\\MapRequestPayload` attribute

controller/error_pages.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,12 @@ store the HTTP status code and message respectively.
114114
and its required ``getStatusCode()`` method. Otherwise, the ``status_code``
115115
will default to ``500``.
116116

117-
Additionally you have access to the Exception with ``exception``, which for example
118-
allows you to output the stack trace using ``{{ exception.traceAsString }}`` or
119-
access any other method on the object. You should be careful with this though,
120-
as this is very likely to expose sensitive data.
117+
Additionally you have access to the :class:`Symfony\\Component\\HttpKernel\\Exception\\HttpException`
118+
object via the ``exception`` Twig variable. For example, if the exception sets a
119+
message (e.g. using ``throw $this->createNotFoundException('The product does not exist')``),
120+
use ``{{ exception.message }}`` to print that message. You can also output the
121+
stack trace using ``{{ exception.traceAsString }}``, but don't do that for end
122+
users because the trace contains sensitive data.
121123

122124
.. tip::
123125

0 commit comments

Comments
 (0)