From ceebc6783a5b652b60a6138b6ef388829e2ae80b Mon Sep 17 00:00:00 2001 From: Dave Mc Nicoll Date: Wed, 11 May 2022 14:09:18 +0000 Subject: [PATCH] - Added basic handling of BODY content from Web-RestMethod from PS --- src/Method/FormContext.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/Method/FormContext.php b/src/Method/FormContext.php index 676f16c..fe10aad 100644 --- a/src/Method/FormContext.php +++ b/src/Method/FormContext.php @@ -25,16 +25,24 @@ class FormContext implements FormContextInterface public ? ResponseInterface $response = null; - public function __construct(ServerRequestInterface $request, ? string $formName = null) + public function __construct(ServerRequestInterface $request, ? string $formName = null) { $this->request = $request; - + if ( $formName ) { - $this->formName = $formName; + $this->formName = $formName; } - + $this->values = $request->getParsedBody() ?: []; + if ( ! $this->values ) { + $content = utf8_encode((string) $request->getBody()); + + if ( $content && ( $json = json_decode($content, true) ) ) { + $this->values = $json; + } + } + $this->files = $request->getUploadedFiles() ?: []; }