Skip to content

Commit

Permalink
Update handler response
Browse files Browse the repository at this point in the history
  • Loading branch information
voltan committed Dec 15, 2024
1 parent 7ef5718 commit 31d0086
Show file tree
Hide file tree
Showing 43 changed files with 115 additions and 114 deletions.
5 changes: 3 additions & 2 deletions src/Handler/Admin/Cache/DeleteHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

namespace Pi\User\Handler\Admin\Cache;

use Laminas\Diactoros\Response\JsonResponse;
use Pi\Core\Response\EscapingJsonResponse;
use Pi\Core\Response\EscapingJsonResponse;
use Pi\Core\Service\CacheService;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -46,6 +47,6 @@ public function handle(ServerRequestInterface $request): ResponseInterface
],
'error' => new \stdClass(),
];
return new JsonResponse($result);
return new EscapingJsonResponse($result);
}
}
4 changes: 2 additions & 2 deletions src/Handler/Admin/Cache/ListHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Pi\User\Handler\Admin\Cache;

use Laminas\Diactoros\Response\JsonResponse;
use Pi\Core\Response\EscapingJsonResponse;
use Pi\Core\Service\CacheService;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -44,6 +44,6 @@ public function handle(ServerRequestInterface $request): ResponseInterface
],
'error' => new \stdClass(),
];
return new JsonResponse($result);
return new EscapingJsonResponse($result);
}
}
4 changes: 2 additions & 2 deletions src/Handler/Admin/Cache/PersistHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Pi\User\Handler\Admin\Cache;

use Laminas\Diactoros\Response\JsonResponse;
use Pi\Core\Response\EscapingJsonResponse;
use Pi\Core\Service\CacheService;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -46,6 +46,6 @@ public function handle(ServerRequestInterface $request): ResponseInterface
],
'error' => new \stdClass(),
];
return new JsonResponse($result);
return new EscapingJsonResponse($result);
}
}
4 changes: 2 additions & 2 deletions src/Handler/Admin/Cache/ViewHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Pi\User\Handler\Admin\Cache;

use Laminas\Diactoros\Response\JsonResponse;
use Pi\Core\Response\EscapingJsonResponse;
use Pi\Core\Service\CacheService;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -44,6 +44,6 @@ public function handle(ServerRequestInterface $request): ResponseInterface
'data' => $item,
'error' => new \stdClass(),
];
return new JsonResponse($result);
return new EscapingJsonResponse($result);
}
}
4 changes: 2 additions & 2 deletions src/Handler/Admin/Permission/Page/ListHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Pi\User\Handler\Admin\Permission\Page;

use Fig\Http\Message\StatusCodeInterface;
use Laminas\Diactoros\Response\JsonResponse;
use Pi\Core\Response\EscapingJsonResponse;
use Pi\User\Service\PermissionService;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -43,6 +43,6 @@ public function handle(ServerRequestInterface $request): ResponseInterface
'error' => new \stdClass(),
];

return new JsonResponse($result, $result['status'] ?? StatusCodeInterface::STATUS_OK);
return new EscapingJsonResponse($result, $result['status'] ?? StatusCodeInterface::STATUS_OK);
}
}
4 changes: 2 additions & 2 deletions src/Handler/Admin/Permission/Resource/ListHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Pi\User\Handler\Admin\Permission\Resource;

use Fig\Http\Message\StatusCodeInterface;
use Laminas\Diactoros\Response\JsonResponse;
use Pi\Core\Response\EscapingJsonResponse;
use Pi\User\Service\PermissionService;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -43,6 +43,6 @@ public function handle(ServerRequestInterface $request): ResponseInterface
'error' => new \stdClass(),
];

return new JsonResponse($result, $result['status'] ?? StatusCodeInterface::STATUS_OK);
return new EscapingJsonResponse($result, $result['status'] ?? StatusCodeInterface::STATUS_OK);
}
}
4 changes: 2 additions & 2 deletions src/Handler/Admin/Permission/Role/ListHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Pi\User\Handler\Admin\Permission\Role;

use Fig\Http\Message\StatusCodeInterface;
use Laminas\Diactoros\Response\JsonResponse;
use Pi\Core\Response\EscapingJsonResponse;
use Pi\User\Service\PermissionService;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -43,6 +43,6 @@ public function handle(ServerRequestInterface $request): ResponseInterface
'error' => new \stdClass(),
];

return new JsonResponse($result, $result['status'] ?? StatusCodeInterface::STATUS_OK);
return new EscapingJsonResponse($result, $result['status'] ?? StatusCodeInterface::STATUS_OK);
}
}
6 changes: 3 additions & 3 deletions src/Handler/Admin/Profile/AddHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Pi\User\Handler\Admin\Profile;

use Laminas\Diactoros\Response\JsonResponse;
use Pi\Core\Response\EscapingJsonResponse;
use Pi\User\Service\AccountService;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -39,10 +39,10 @@ public function handle(ServerRequestInterface $request): ResponseInterface
if (isset($result['id']) && !empty($result)) {
$this->accountService->addRoleAccountByAdmin($requestBody, $result, $operator);
} else {
return new JsonResponse($result);
return new EscapingJsonResponse($result);
}

return new JsonResponse(
return new EscapingJsonResponse(
[
'result' => true,
'data' => $result,
Expand Down
4 changes: 2 additions & 2 deletions src/Handler/Admin/Profile/CleanHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Pi\User\Handler\Admin\Profile;

use Fig\Http\Message\StatusCodeInterface;
use Laminas\Diactoros\Response\JsonResponse;
use Pi\Core\Response\EscapingJsonResponse;
use Pi\User\Service\AccountService;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -47,6 +47,6 @@ public function handle(ServerRequestInterface $request): ResponseInterface
'error' => [],
];

return new JsonResponse($result, $result['status'] ?? StatusCodeInterface::STATUS_OK);
return new EscapingJsonResponse($result, $result['status'] ?? StatusCodeInterface::STATUS_OK);
}
}
4 changes: 2 additions & 2 deletions src/Handler/Admin/Profile/DeleteHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Pi\User\Handler\Admin\Profile;

use Fig\Http\Message\StatusCodeInterface;
use Laminas\Diactoros\Response\JsonResponse;
use Pi\Core\Response\EscapingJsonResponse;
use Pi\User\Service\AccountService;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -38,6 +38,6 @@ public function handle(ServerRequestInterface $request): ResponseInterface
$operator = $request->getAttribute('account');
$result = $this->accountService->deleteUserByAdmin($requestBody, $operator);

return new JsonResponse($result, $result['status'] ?? StatusCodeInterface::STATUS_OK);
return new EscapingJsonResponse($result, $result['status'] ?? StatusCodeInterface::STATUS_OK);
}
}
4 changes: 2 additions & 2 deletions src/Handler/Admin/Profile/EditHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Pi\User\Handler\Admin\Profile;

use Laminas\Diactoros\Response\JsonResponse;
use Pi\Core\Response\EscapingJsonResponse;
use Pi\User\Service\AccountService;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -47,7 +47,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface
$this->accountService->updateAccountRoles($requestBody['roles'], $updatedAccount, 'all', $operator);
}

return new JsonResponse(
return new EscapingJsonResponse(
[
'result' => true,
'data' => $updatedAccount,
Expand Down
4 changes: 2 additions & 2 deletions src/Handler/Admin/Profile/ExportHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Pi\User\Handler\Admin\Profile;

use Fig\Http\Message\StatusCodeInterface;
use Laminas\Diactoros\Response\JsonResponse;
use Pi\Core\Response\EscapingJsonResponse;
use Pi\Media\Service\MediaService;
use Pi\User\Service\AccountService;
use Pi\User\Service\ExportService;
Expand Down Expand Up @@ -51,6 +51,6 @@ public function handle(ServerRequestInterface $request): ResponseInterface
$account = $this->accountService->getAccountList($params);
$export = $this->exportService->exportData($account);
$result = $this->mediaService->streamFile($export);
return new JsonResponse($result, StatusCodeInterface::STATUS_OK);
return new EscapingJsonResponse($result, StatusCodeInterface::STATUS_OK);
}
}
4 changes: 2 additions & 2 deletions src/Handler/Admin/Profile/ListHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Pi\User\Handler\Admin\Profile;

use Laminas\Diactoros\Response\JsonResponse;
use Pi\Core\Response\EscapingJsonResponse;
use Pi\User\Service\AccountService;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -36,7 +36,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface
$requestBody = $request->getParsedBody();
$result = $this->accountService->getAccountProfileList($requestBody);

return new JsonResponse(
return new EscapingJsonResponse(
[
'result' => true,
'data' => $result,
Expand Down
6 changes: 3 additions & 3 deletions src/Handler/Admin/Profile/PasswordHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
namespace Pi\User\Handler\Admin\Profile;

use Fig\Http\Message\StatusCodeInterface;
use Laminas\Diactoros\Response\JsonResponse;
use Pi\Core\Response\EscapingJsonResponse;
use Pi\User\Service\AccountService;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Pi\User\Service\AccountService;

class PasswordHandler implements RequestHandlerInterface
{
Expand Down Expand Up @@ -37,6 +37,6 @@ public function handle(ServerRequestInterface $request): ResponseInterface
$requestBody = $request->getParsedBody();
$operator = $request->getAttribute('account');
$result = $this->accountService->updatePasswordByAdmin($requestBody, $operator);
return new JsonResponse($result, $result['status'] ?? StatusCodeInterface::STATUS_OK);
return new EscapingJsonResponse($result, $result['status'] ?? StatusCodeInterface::STATUS_OK);
}
}
6 changes: 3 additions & 3 deletions src/Handler/Admin/Profile/StatusHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
namespace Pi\User\Handler\Admin\Profile;

use Fig\Http\Message\StatusCodeInterface;
use Laminas\Diactoros\Response\JsonResponse;
use Pi\Core\Response\EscapingJsonResponse;
use Pi\User\Service\AccountService;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Pi\User\Service\AccountService;

class StatusHandler implements RequestHandlerInterface
{
Expand Down Expand Up @@ -38,6 +38,6 @@ public function handle(ServerRequestInterface $request): ResponseInterface
$operator = $request->getAttribute('account');
$result = $this->accountService->updateStatusByAdmin($requestBody, $operator);

return new JsonResponse($result, $result['status'] ?? StatusCodeInterface::STATUS_OK);
return new EscapingJsonResponse($result, $result['status'] ?? StatusCodeInterface::STATUS_OK);
}
}
6 changes: 3 additions & 3 deletions src/Handler/Admin/Profile/ViewHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
namespace Pi\User\Handler\Admin\Profile;

use Fig\Http\Message\StatusCodeInterface;
use Laminas\Diactoros\Response\JsonResponse;
use Pi\Core\Response\EscapingJsonResponse;
use Pi\User\Service\AccountService;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\StreamFactoryInterface;
use Psr\Http\Server\RequestHandlerInterface;
use Pi\User\Service\AccountService;

class ViewHandler implements RequestHandlerInterface
{
Expand Down Expand Up @@ -46,6 +46,6 @@ public function handle(ServerRequestInterface $request): ResponseInterface
'error' => [],
];

return new JsonResponse($result, $result['status'] ?? StatusCodeInterface::STATUS_OK);
return new EscapingJsonResponse($result, $result['status'] ?? StatusCodeInterface::STATUS_OK);
}
}
6 changes: 3 additions & 3 deletions src/Handler/Admin/Role/AddHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Pi\User\Handler\Admin\Role;

use Laminas\Diactoros\Response\JsonResponse;
use Pi\Core\Response\EscapingJsonResponse;
use Pi\User\Service\RoleService;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -53,7 +53,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface
}

if ($isDuplicate || !isset($requestBody['name']) || empty($requestBody['name'])) {
return new JsonResponse(
return new EscapingJsonResponse(
[
'result' => false,
'data' => new stdClass(),
Expand All @@ -68,7 +68,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface
// Add role
$result = $this->roleService->addRoleResource($requestBody, $operator);

return new JsonResponse(
return new EscapingJsonResponse(
[
'result' => true,
'data' => $result,
Expand Down
4 changes: 2 additions & 2 deletions src/Handler/Admin/Role/DeleteHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Pi\User\Handler\Admin\Role;

use Laminas\Diactoros\Response\JsonResponse;
use Pi\Core\Response\EscapingJsonResponse;
use Pi\User\Service\RoleService;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -40,7 +40,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface
// Delete
$this->roleService->deleteRoleResource($requestBody, $operator);

return new JsonResponse(
return new EscapingJsonResponse(
[
'result' => true,
'data' => new stdClass(),
Expand Down
4 changes: 2 additions & 2 deletions src/Handler/Admin/Role/EditHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Pi\User\Handler\Admin\Role;

use Laminas\Diactoros\Response\JsonResponse;
use Pi\Core\Response\EscapingJsonResponse;
use Pi\User\Service\RoleService;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -40,7 +40,7 @@ public function handle(ServerRequestInterface $request): ResponseInterface
// Update
$this->roleService->updateRoleResource($requestBody, $operator);

return new JsonResponse(
return new EscapingJsonResponse(
[
'result' => true,
'data' => new stdClass(),
Expand Down
4 changes: 2 additions & 2 deletions src/Handler/Admin/Role/ListHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Pi\User\Handler\Admin\Role;

use Laminas\Diactoros\Response\JsonResponse;
use Pi\Core\Response\EscapingJsonResponse;
use Pi\User\Service\RoleService;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -49,6 +49,6 @@ public function handle(ServerRequestInterface $request): ResponseInterface
],
'error' => new \stdClass(),
];
return new JsonResponse($result);
return new EscapingJsonResponse($result);
}
}
Loading

0 comments on commit 31d0086

Please sign in to comment.