Compare commits
No commits in common. "531f786747501faf7b0f37c0dab01cddaa734a3b" and "b08325049b31f58125c4f225ba8bdccd182ab1ed" have entirely different histories.
531f786747
...
b08325049b
@ -7,7 +7,6 @@ use Picea\Extension\Extension,
|
|||||||
|
|
||||||
use Picea\Compiler\Context;
|
use Picea\Compiler\Context;
|
||||||
|
|
||||||
use Psr\Http\Message\RequestInterface;
|
|
||||||
use Psr\Http\Message\ServerRequestInterface;
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
|
||||||
class Request implements Extension {
|
class Request implements Extension {
|
||||||
@ -47,7 +46,7 @@ class Request implements Extension {
|
|||||||
|
|
||||||
public function post(? string $variableName = null, $default = null)
|
public function post(? string $variableName = null, $default = null)
|
||||||
{
|
{
|
||||||
return $variableName === null ? $this->_post() : static::arrayGet($this->_post(), $variableName) ?? $default;
|
return $variableName === null ? $this->request->getParsedBody() : static::arrayGet($this->request->getParsedBody(), $variableName) ?? $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function request(? string $variableName = null, $default = null)
|
public function request(? string $variableName = null, $default = null)
|
||||||
@ -76,19 +75,4 @@ class Request implements Extension {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _post() : array
|
|
||||||
{
|
|
||||||
$post = $this->request->getParsedBody();
|
|
||||||
|
|
||||||
if ( ! $post ) {
|
|
||||||
$content = utf8_encode((string) $this->request->getBody());
|
|
||||||
|
|
||||||
if ( $content && ( $json = json_decode($content, true) ) ) {
|
|
||||||
$post = $json;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $post ?: [];
|
|
||||||
}
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user