- Some work done on entity generation
This commit is contained in:
1 parent
05975089e5
commit
2dc71cd350
12 files changed
+94
-28
No files matched your search
@@ -24,8 +24,6 @@ class ApiRenderer implements MiddlewareInterface {
|
||||
$response = $handler->handle($request);
|
||||
}
|
||||
catch(\Throwable $ex) {
|
||||
|
||||
|
||||
if (static::awaitingJson($request)) {
|
||||
return HttpFactory::createJsonResponse([
|
||||
'status' => 'failed',
|
||||
@@ -48,7 +46,7 @@ class ApiRenderer implements MiddlewareInterface {
|
||||
$payload = $response->getPayload();
|
||||
|
||||
# For now, we match only response having a 'data' field
|
||||
if (isset($payload['data'])) {
|
||||
if ( (is_array($payload) || $payload instanceof \ArrayAccess) && isset($payload['data'])) {
|
||||
return HttpFactory::createJsonResponse([
|
||||
'status' => 'success',
|
||||
'ts' => time(),
|
||||
@@ -84,4 +82,19 @@ class ApiRenderer implements MiddlewareInterface {
|
||||
{
|
||||
return str_contains(strtolower($request->getHeaderLine('content-type')), 'json');
|
||||
}
|
||||
|
||||
public static function encodeHtml(iterable& $array) : iterable
|
||||
{
|
||||
foreach($array as &$item) {
|
||||
if (is_array($item)) {
|
||||
$item = static::encodeHtml($item);
|
||||
}
|
||||
elseif (is_string($item)) {
|
||||
dump($item);
|
||||
$item = htmlspecialchars($item);
|
||||
}
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user