Add ServerRequest::getParsedBodyParam method
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
parent
8e4d6229a9
commit
1a2d7804d2
@ -160,7 +160,7 @@ class VariablesController extends AbstractController
|
||||
return;
|
||||
}
|
||||
|
||||
$value = (string) $request->getParam('varValue');
|
||||
$value = (string) $request->getParsedBodyParam('varValue');
|
||||
$variableName = (string) $vars['name'];
|
||||
$matches = [];
|
||||
$variableType = ServerVariablesProvider::getImplementation()->getVariableType($variableName);
|
||||
|
||||
@ -315,6 +315,26 @@ class ServerRequest implements ServerRequestInterface
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $default
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getParsedBodyParam(string $param, $default = null)
|
||||
{
|
||||
$postParams = $this->getParsedBody();
|
||||
|
||||
if (is_array($postParams) && isset($postParams[$param])) {
|
||||
return $postParams[$param];
|
||||
}
|
||||
|
||||
if (is_object($postParams) && property_exists($postParams, $param)) {
|
||||
return $postParams->$param;
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
public function isPost(): bool
|
||||
{
|
||||
return $this->getMethod() === 'POST';
|
||||
|
||||
@ -183,7 +183,7 @@ Core::setDatabaseAndTableFromRequest($containerBuilder);
|
||||
*/
|
||||
$sql_query = '';
|
||||
if ($request->isPost()) {
|
||||
$sql_query = $request->getParam('sql_query', '');
|
||||
$sql_query = $request->getParsedBodyParam('sql_query', '');
|
||||
}
|
||||
|
||||
$containerBuilder->setParameter('sql_query', $sql_query);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user