CORS
This commit is contained in:
@ -12,6 +12,16 @@ class Inmobiliarias
|
||||
{
|
||||
use withJson;
|
||||
|
||||
public function __invoke(ServerRequestInterface $request, ResponseInterface $response, Repository\Inmobiliaria $inmobiliariaRepository): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'inmobiliarias' => []
|
||||
];
|
||||
try {
|
||||
$output['inmobiliarias'] = $inmobiliariaRepository->fetchAll('razon');
|
||||
} catch (EmptyResult) {}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function cuentas(ServerRequestInterface $request, ResponseInterface $response,
|
||||
Repository\Inmobiliaria $inmobiliariaRepository,
|
||||
Repository\Inmobiliaria\Cuenta $cuentaRepository, int $inmobiliaria_rut): ResponseInterface
|
||||
|
@ -20,8 +20,8 @@ class Inmobiliarias
|
||||
$inmobiliarias = [];
|
||||
try {
|
||||
$inmobiliarias = array_map(function($row) use ($inmobiliariaRepository) {
|
||||
return $inmobiliariaRepository->load((array) $row);
|
||||
}, $this->fetchRedis($redisService, $redisKey));
|
||||
return $inmobiliariaRepository->load($row);
|
||||
}, $this->fetchRedis($redisService, $redisKey, true));
|
||||
} catch (EmptyRedis) {
|
||||
try {
|
||||
$inmobiliarias = $inmobiliariaRepository->fetchAll();
|
||||
|
@ -6,13 +6,13 @@ use Incoviba\Service;
|
||||
|
||||
trait withRedis
|
||||
{
|
||||
public function fetchRedis(Service\Redis $redisService, string $redisKey): mixed
|
||||
public function fetchRedis(Service\Redis $redisService, string $redisKey, ?bool $asArray = null): mixed
|
||||
{
|
||||
$jsonString = $redisService->get($redisKey);
|
||||
if ($jsonString === null) {
|
||||
throw new EmptyRedis($redisKey);
|
||||
}
|
||||
return json_decode($jsonString);
|
||||
return json_decode($jsonString, $asArray);
|
||||
}
|
||||
public function saveRedis(Service\Redis $redisService, string $redisKey, mixed $value, ?int $expiration = null): void
|
||||
{
|
||||
|
Reference in New Issue
Block a user