Listado proyectos
This commit is contained in:
53
app/src/Controller/API/Proyectos/EstadosProyectos.php
Normal file
53
app/src/Controller/API/Proyectos/EstadosProyectos.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
namespace Incoviba\Controller\API\Proyectos;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Incoviba\Common\Implement\Exception\EmptyResult;
|
||||
use Incoviba\Controller\API\emptyBody;
|
||||
use Incoviba\Controller\API\withJson;
|
||||
use Incoviba\Repository;
|
||||
|
||||
class EstadosProyectos
|
||||
{
|
||||
use withJson, emptyBody;
|
||||
public function byProyecto(ServerRequestInterface $request, ResponseInterface $response, Repository\Proyecto\EstadoProyecto $estadoProyectoRepository, int $proyecto_id): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'proyecto_id' => $proyecto_id,
|
||||
'estados' => []
|
||||
];
|
||||
try {
|
||||
$output['estados'] = $estadoProyectoRepository->fetchByProyecto($proyecto_id);
|
||||
} catch (EmptyResult) {
|
||||
return $this->emptyBody($response);
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function currentByProyecto(ServerRequestInterface $request, ResponseInterface $response, Repository\Proyecto\EstadoProyecto $estadoProyectoRepository, int $proyecto_id): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'proyecto_id' => $proyecto_id,
|
||||
'estado' => null
|
||||
];
|
||||
try {
|
||||
$output['estado'] = $estadoProyectoRepository->fetchCurrentByProyecto($proyecto_id);
|
||||
} catch (EmptyResult) {
|
||||
return $this->emptyBody($response);
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
public function firstByProyecto(ServerRequestInterface $request, ResponseInterface $response, Repository\Proyecto\EstadoProyecto $estadoProyectoRepository, int $proyecto_id): ResponseInterface
|
||||
{
|
||||
$output = [
|
||||
'proyecto_id' => $proyecto_id,
|
||||
'estado' => null
|
||||
];
|
||||
try {
|
||||
$output['estado'] = $estadoProyectoRepository->fetchFirstByProyecto($proyecto_id);
|
||||
} catch (EmptyResult) {
|
||||
return $this->emptyBody($response);
|
||||
}
|
||||
return $this->withJson($response, $output);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user