Contratos desde proyectos

This commit is contained in:
Juan Pablo Vial
2025-03-03 21:46:53 -03:00
parent aeeca65d94
commit 8ea4995f6b
3 changed files with 38 additions and 0 deletions

View File

@ -4,6 +4,7 @@ namespace Incoviba\Controller\API;
use Incoviba\Common\Implement\Exception\EmptyRedis;
use Incoviba\Common\Implement\Exception\EmptyResult;
use Incoviba\Controller\withRedis;
use Incoviba\Exception\ServiceAction\Read;
use Incoviba\Model;
use Incoviba\Repository;
use Incoviba\Service;
@ -170,4 +171,20 @@ class Proyectos
} catch (EmptyResult) {}
return $this->withJson($response, $output);
}
public function brokers(ServerRequestInterface $request, ResponseInterface $response,
Repository\Proyecto $proyectoRepository, Service\Proyecto\Broker\Contract $contractService,
int $proyecto_id): ResponseInterface
{
$output = [
'proyecto_id' => $proyecto_id,
'contracts' => []
];
try {
$proyecto = $proyectoRepository->fetchById($proyecto_id);
$output['contracts'] = $contractService->getByProject($proyecto->id);
} catch (EmptyResult | Read $exception) {
return $this->withError($response, $exception);
}
return $this->withJson($response, $output);
}
}