Implemented repository mapper, and venta show
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller;
|
||||
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Alias\View;
|
||||
@ -14,8 +15,13 @@ class Proyectos
|
||||
}
|
||||
public function list(ServerRequestInterface $request, ResponseInterface $response, Repository\Proyecto $proyectoRepository): ResponseInterface
|
||||
{
|
||||
$proyectos = $proyectoRepository->fetchAllActive();
|
||||
$response->getBody()->write(json_encode(['proyectos' => $proyectos, 'total' => count($proyectos)]));
|
||||
$output = ['total' => 0];
|
||||
try {
|
||||
$proyectos = $proyectoRepository->fetchAllActive();
|
||||
$output['proyectos'] = $proyectos;
|
||||
$output['total'] = count($proyectos);
|
||||
} catch (EmptyResult) {}
|
||||
$response->getBody()->write(json_encode($output));
|
||||
return $response->withHeader('Content-Type', 'application/json');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user