api getQueryParam return string
This commit is contained in:
@@ -29,6 +29,8 @@
|
||||
|
||||
namespace Espo\Controllers;
|
||||
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
|
||||
use Espo\Core\{
|
||||
Api\Request,
|
||||
Record\SearchParamsFetcher,
|
||||
@@ -97,7 +99,11 @@ class Stream
|
||||
$maxSize = $searchParams->getMaxSize();
|
||||
|
||||
$after = $request->getQueryParam('after');
|
||||
$where = $request->getQueryParam('where');
|
||||
$where = $request->getQueryParams()['where'] ?? null;
|
||||
|
||||
if ($where !== null && !is_array($where)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$result = $this->service->find($scope, $id, [
|
||||
'offset' => $offset,
|
||||
|
||||
@@ -45,10 +45,8 @@ interface Request
|
||||
|
||||
/**
|
||||
* Get a query parameter.
|
||||
*
|
||||
* @return string|string[]|null
|
||||
*/
|
||||
public function getQueryParam(string $name);
|
||||
public function getQueryParam(string $name): ?string;
|
||||
|
||||
/**
|
||||
* Get all query parameters.
|
||||
|
||||
@@ -50,14 +50,11 @@ class RequestNull implements ApiRequest
|
||||
/**
|
||||
* @return null
|
||||
*/
|
||||
public function getQueryParam(string $name)
|
||||
public function getQueryParam(string $name): ?string
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getQueryParams(): array
|
||||
{
|
||||
return [];
|
||||
|
||||
@@ -85,7 +85,7 @@ class RequestWrapper implements ApiRequest
|
||||
return $this->getRouteParam($name);
|
||||
}
|
||||
|
||||
return $this->getQueryParam($name);
|
||||
return $this->request->getQueryParams()[$name] ?? null;
|
||||
}
|
||||
|
||||
public function hasRouteParam(string $name): bool
|
||||
@@ -111,23 +111,17 @@ class RequestWrapper implements ApiRequest
|
||||
return array_key_exists($name, $this->request->getQueryParams());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|string[]|null
|
||||
*/
|
||||
public function getQueryParam(string $name)
|
||||
public function getQueryParam(string $name): ?string
|
||||
{
|
||||
$value = $this->request->getQueryParams()[$name] ?? null;
|
||||
|
||||
if ($value === null) {
|
||||
if (!is_string($value)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string,string|string[]>
|
||||
*/
|
||||
public function getQueryParams(): array
|
||||
{
|
||||
return $this->request->getQueryParams();
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
namespace Espo\Core\Controllers;
|
||||
|
||||
use Espo\Core\Exceptions\Forbidden;
|
||||
use Espo\Core\Exceptions\BadRequest;
|
||||
|
||||
use Espo\Services\RecordTree as Service;
|
||||
use Espo\Core\Api\Request;
|
||||
|
||||
@@ -52,10 +54,14 @@ class RecordTree extends Record
|
||||
return (object) $this->actionListTree($request->getRouteParams(), $request->getParsedBody(), $request);
|
||||
}
|
||||
|
||||
$where = $request->getQueryParam('where');
|
||||
$where = $request->getQueryParams()['where'] ?? null;
|
||||
$parentId = $request->getQueryParam('parentId');
|
||||
$maxDepth = $request->getQueryParam('maxDepth');
|
||||
$onlyNotEmpty = (bool) $request->getQueryParam('onlyNotEmpty');
|
||||
|
||||
if ($where !== null && !is_array($where)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
if ($maxDepth !== null) {
|
||||
$maxDepth = (int) $maxDepth;
|
||||
|
||||
@@ -92,7 +92,12 @@ class SearchParamsFetcher
|
||||
{
|
||||
$params = [];
|
||||
|
||||
$params['where'] = $request->getQueryParam('where');
|
||||
$params['where'] = $request->getQueryParams()['where'] ?? null;
|
||||
|
||||
if ($params['where'] !== null && !is_array($params['where'])) {
|
||||
$params['where'] = null;
|
||||
}
|
||||
|
||||
$params['maxSize'] = $request->getQueryParam('maxSize');
|
||||
$params['offset'] = $request->getQueryParam('offset');
|
||||
|
||||
@@ -141,12 +146,12 @@ class SearchParamsFetcher
|
||||
$params['primaryFilter'] = $request->getQueryParam('primaryFilter');
|
||||
}
|
||||
|
||||
if ($request->getQueryParam('boolFilterList')) {
|
||||
$params['boolFilterList'] = $request->getQueryParam('boolFilterList');
|
||||
if ($request->getQueryParams()['boolFilterList'] ?? null) {
|
||||
$params['boolFilterList'] = (array) $request->getQueryParams()['boolFilterList'];
|
||||
}
|
||||
|
||||
if ($request->getQueryParam('filterList')) {
|
||||
$params['filterList'] = $request->getQueryParam('filterList');
|
||||
if ($request->getQueryParams()['filterList'] ?? null) {
|
||||
$params['filterList'] = (array) $request->getQueryParams()['filterList'];
|
||||
}
|
||||
|
||||
if ($request->getQueryParam('select')) {
|
||||
|
||||
@@ -172,7 +172,7 @@ class Activities
|
||||
$offset = $searchParams->getOffset();
|
||||
$maxSize = $searchParams->getMaxSize();
|
||||
|
||||
$entityTypeList = $request->getQueryParam('entityTypeList');
|
||||
$entityTypeList = (array) ($request->getQueryParams()['entityTypeList'] ?? null);
|
||||
|
||||
$futureDays = intval($request->getQueryParam('futureDays'));
|
||||
|
||||
|
||||
@@ -120,17 +120,9 @@ class CampaignUrl implements EntryPoint
|
||||
}
|
||||
|
||||
if ($emailAddress && $hash) {
|
||||
if (!is_string($emailAddress) || !is_string($hash)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$this->processWithHash($trackingUrl, $emailAddress, $hash);
|
||||
}
|
||||
else if ($uid && $hash) {
|
||||
if (!is_string($uid) || !is_string($hash)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$this->processWithUniqueId($trackingUrl, $uid, $hash);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -91,10 +91,6 @@ class SubscribeAgain implements EntryPoint
|
||||
$hash = $request->getQueryParam('hash') ?? null;
|
||||
|
||||
if ($emailAddress && $hash) {
|
||||
if (!is_string($emailAddress) || !is_string($hash)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$this->processWithHash($emailAddress, $hash);
|
||||
|
||||
return;
|
||||
|
||||
@@ -96,16 +96,12 @@ class Unsubscribe implements EntryPoint
|
||||
$hash = $request->getQueryParam('hash') ?? null;
|
||||
|
||||
if ($emailAddress && $hash) {
|
||||
if (!is_string($emailAddress) || !is_string($hash)) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$this->processWithHash($emailAddress, $hash);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$id || !is_string($id)) {
|
||||
if (!$id) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user