From b478e211735d72f4ccbcfbfcb6b35c9bee9fc54e Mon Sep 17 00:00:00 2001 From: Kevin Bond Date: Thu, 20 Apr 2023 11:33:34 -0400 Subject: [PATCH] [HttpFoundation] document `Request::getPayload()` --- components/http_foundation.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/components/http_foundation.rst b/components/http_foundation.rst index 0711d4764e3..6f6cb5b524e 100644 --- a/components/http_foundation.rst +++ b/components/http_foundation.rst @@ -216,6 +216,18 @@ If the request body is a JSON string, it can be accessed using $data = $request->toArray(); +If the request data could be ``$_POST`` data *or* a JSON string, you can use +the :method:`Symfony\\Component\\HttpFoundation\\Request::getPayload` method +which returns an instance of :class:`Symfony\\Component\\HttpFoundation\\InputBag` +wrapping this data:: + + $data = $request->getPayload(); + +.. versionadded:: 6.3 + + The :method:`Symfony\\Component\\HttpFoundation\\Request::getPayload` + method was introduced in Symfony 6.3. + Identifying a Request ~~~~~~~~~~~~~~~~~~~~~