Skip to content

Commit

Permalink
Fixed the controllers due to the Core changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslanbaidan committed Aug 22, 2023
1 parent ce0c4ba commit 1325a85
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 24 deletions.
16 changes: 8 additions & 8 deletions src/Controller/ApiAmvsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,13 @@ public function get($id)
public function create($data)
{
if ($this->isBatchData($data)) {
return $this->getSuccessfulJsonResponse([
'id' => current($this->amvService->createAmvItems($data))
]);
$result = $this->amvService->createAmvItems($data);
} else {
$this->validatePostParams($this->postAmvDataInputValidator, $data);
$result = $this->amvService->create($data)->getUuid();
}

$this->validatePostParams($this->postAmvDataInputValidator, $data);

return $this->getSuccessfulJsonResponse([
'id' => $this->amvService->create($data),
]);
return $this->getSuccessfulJsonResponse(['id' => $result]);
}

/**
Expand Down Expand Up @@ -96,6 +93,9 @@ public function patchList($data)
return $this->getSuccessfulJsonResponse();
}

/**
* @param string $id
*/
public function delete($id)
{
$this->amvService->delete($id);
Expand Down
3 changes: 2 additions & 1 deletion src/Controller/ApiAnrInstancesMetadataFieldsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use Monarc\Core\Controller\Handler\AbstractRestfulControllerRequestHandler;
use Monarc\Core\Controller\Handler\ControllerRequestResponseHandlerTrait;
use Monarc\Core\Exception\Exception;
use Monarc\Core\Model\Entity\Anr;
use Monarc\Core\Service\AnrInstanceMetadataFieldService;

Expand Down Expand Up @@ -54,7 +55,7 @@ public function create($data)
$anr = $this->getRequest()->getAttribute('anr');

return $this->getSuccessfulJsonResponse([
'id' => $this->anrInstanceMetadataFieldService->create($anr, $data),
'id' => $this->anrInstanceMetadataFieldService->create($anr, $data)->getId(),
]);
}

Expand Down
29 changes: 16 additions & 13 deletions src/Controller/ApiOperationalRisksScalesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,29 +44,19 @@ public function create($data)
$anr = $this->getRequest()->getAttribute('anr');

return $this->getSuccessfulJsonResponse([
'id' => $this->operationalRiskScaleService->createOperationalRiskScaleType($anr, $data),
'id' => $this->operationalRiskScaleService->createOperationalRiskScaleType($anr, $data)->getId(),
]);
}

/**
* @param array $data
*/
public function deleteList($data)
public function update($id, $data)
{
/** @var Anr $anr */
$anr = $this->getRequest()->getAttribute('anr');

$this->operationalRiskScaleService->deleteOperationalRiskScaleTypes($anr, $data);

return $this->getSuccessfulJsonResponse();
}

/**
* @param array $data
*/
public function update($id, $data)
{
$this->operationalRiskScaleService->update((int)$id, $data);
$this->operationalRiskScaleService->updateScaleType($anr, (int)$id, $data);

return $this->getSuccessfulJsonResponse();
}
Expand Down Expand Up @@ -108,4 +98,17 @@ public function patchList($data)

return $this->getSuccessfulJsonResponse();
}

/**
* @param array $data
*/
public function deleteList($data)
{
/** @var Anr $anr */
$anr = $this->getRequest()->getAttribute('anr');

$this->operationalRiskScaleService->deleteOperationalRiskScaleTypes($anr, $data);

return $this->getSuccessfulJsonResponse();
}
}
7 changes: 5 additions & 2 deletions src/Controller/ApiSoaScaleCommentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ public function getList()
*/
public function update($id, $data)
{
$this->soaScaleCommentService->update((int)$id, $data);
/** @var Anr $anr */
$anr = $this->getRequest()->getAttribute('anr');

$this->soaScaleCommentService->update($anr, (int)$id, $data);

return $this->getSuccessfulJsonResponse();
}
Expand All @@ -50,7 +53,7 @@ public function patchList($data)
$anr = $this->getRequest()->getAttribute('anr');
$language = $this->params()->fromQuery("language");

$this->soaScaleCommentService->createOrHideSoaScaleComment($anr, $data);
$this->soaScaleCommentService->createOrHideSoaScaleComments($anr, $data);

return $this->getSuccessfulJsonResponse([
'data' => $this->soaScaleCommentService->getSoaScaleComments($anr, $language),
Expand Down

0 comments on commit 1325a85

Please sign in to comment.