diff --git a/src/Controller/ApiAnrRisksController.php b/src/Controller/ApiAnrRisksController.php index 8bbd3e7..11a1a86 100755 --- a/src/Controller/ApiAnrRisksController.php +++ b/src/Controller/ApiAnrRisksController.php @@ -23,13 +23,16 @@ public function __construct(InstanceRiskService $instanceRiskService) $this->instanceRiskService = $instanceRiskService; } + /** + * @param int|null $id Instance ID. + */ public function get($id) { /** @var Anr $anr */ $anr = $this->getRequest()->getAttribute('anr'); $params = $this->prepareParams(); - $risks = $this->instanceRiskService->getInstanceRisks($anr, (int)$id, $params); + $risks = $this->instanceRiskService->getInstanceRisks($anr, $id === null ? null : (int)$id, $params); return $this->getPreparedJsonResponse([ 'count' => \count($risks), @@ -41,19 +44,7 @@ public function get($id) public function getList() { - /** @var Anr $anr */ - $anr = $this->getRequest()->getAttribute('anr'); - - $params = $this->prepareParams(); - - $risks = $this->instanceRiskService->getInstanceRisks($anr, null, $params); - - return $this->getPreparedJsonResponse([ - 'count' => \count($risks), - 'risks' => $params['limit'] > 0 ? - \array_slice($risks, ($params['page'] - 1) * $params['limit'], $params['limit']) - : $risks, - ]); + return $this->get(null); } protected function prepareParams(): array diff --git a/src/Controller/ApiAnrRisksOpController.php b/src/Controller/ApiAnrRisksOpController.php index ae1962b..936c5d2 100644 --- a/src/Controller/ApiAnrRisksOpController.php +++ b/src/Controller/ApiAnrRisksOpController.php @@ -31,9 +31,8 @@ public function get($id) /** @var Anr $anr */ $anr = $this->getRequest()->getAttribute('anr'); $params = $this->parseParams(); - $id = $id === null ? null : (int)$id; - $risks = $this->instanceRiskOpService->getOperationalRisks($anr, (int)$id, $params); + $risks = $this->instanceRiskOpService->getOperationalRisks($anr, $id === null ? null : (int)$id, $params); return $this->getPreparedJsonResponse([ 'count' => \count($risks), diff --git a/src/Controller/ApiAnrScalesTypesController.php b/src/Controller/ApiAnrScalesTypesController.php index b594496..192a525 100755 --- a/src/Controller/ApiAnrScalesTypesController.php +++ b/src/Controller/ApiAnrScalesTypesController.php @@ -9,7 +9,6 @@ use Monarc\Core\Controller\Handler\AbstractRestfulControllerRequestHandler; use Monarc\Core\Controller\Handler\ControllerRequestResponseHandlerTrait; -use Monarc\Core\InputFormatter\ScaleImpactType\GetScaleImpactTypesInputFormatter; use Monarc\Core\Model\Entity\Anr; use Monarc\Core\Service\ScaleImpactTypeService; @@ -19,21 +18,17 @@ class ApiAnrScalesTypesController extends AbstractRestfulControllerRequestHandle private ScaleImpactTypeService $scaleImpactTypeService; - private GetScaleImpactTypesInputFormatter $getScaleImpactTypesInputFormatter; - - public function __construct( - ScaleImpactTypeService $scaleImpactTypeService, - GetScaleImpactTypesInputFormatter $getScaleImpactTypesInputFormatter - ) { + public function __construct(ScaleImpactTypeService $scaleImpactTypeService) + { $this->scaleImpactTypeService = $scaleImpactTypeService; - $this->getScaleImpactTypesInputFormatter = $getScaleImpactTypesInputFormatter; } public function getList() { - $formattedParams = $this->getFormattedInputParams($this->getScaleImpactTypesInputFormatter); + /** @var Anr $anr */ + $anr = $this->getRequest()->getAttribute('anr'); - $scaleImpactTypesList = $this->scaleImpactTypeService->getList($formattedParams); + $scaleImpactTypesList = $this->scaleImpactTypeService->getList($anr); return $this->getPreparedJsonResponse([ 'count' => \count($scaleImpactTypesList),