- Added basic handling of BODY content from Web-RestMethod from PS

This commit is contained in:
Dave Mc Nicoll 2022-05-11 14:09:18 +00:00
parent 83fee32ac0
commit ceebc6783a
1 changed files with 12 additions and 4 deletions

View File

@ -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() ?: [];
}