Skip to content

Commit

Permalink
revert the lost getlist for multiple model selection and some phpcs
Browse files Browse the repository at this point in the history
  • Loading branch information
jerolomb committed Oct 7, 2022
1 parent 3ee7a43 commit 34c2ed3
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions src/Service/ModelService.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,28 @@ class ModelService extends AbstractService
/**
* @inheritdoc
*/
public function getList($page = 1, $limit = 25, $order = null, $filter = null, $filterAnd = null, $scope = 'BO')
{
public function getList(
$page = 1,
$limit = 25,
$order = null,
$filter = null,
$filterAnd = null,
$scope = 'BO'
) {
$joinModel = -1;

if ($scope == 'FO') {
$filterAnd['isGeneric'] = 1;
$client = current($this->clientTable->fetchAll());
$client = $this->clientTable->findTheClient();

if ($client) {
$joinModel = $client['model_id'];
$joinModel = $client->getModels()
->map(
function ($obj) {
return $obj->getModelId();
}
)
->getValues();
}
}

Expand Down Expand Up @@ -198,8 +210,16 @@ public function verifyBeforeUpdate($model, $data)
if (!empty($assetsIds)) {
$amvs = $this->get('amvTable')->getEntityByFields(['asset' => $assetsIds]);
foreach ($amvs as $amv) {
if ($amv->get('asset')->get('mode') == MonarcObject::MODE_SPECIFIC && $amv->get('threat')->get('mode') == MonarcObject::MODE_GENERIC && $amv->get('vulnerability')->get('mode') == MonarcObject::MODE_GENERIC) {
throw new \Monarc\Core\Exception\Exception('You can not make this change. The level of integrity between the model and its objects would corrupt', 412);
if ($amv->get('asset')->get('mode') == MonarcObject::MODE_SPECIFIC
&& $amv->get('threat')->get('mode') == MonarcObject::MODE_GENERIC
&& $amv->get('vulnerability')->get('mode') == MonarcObject::MODE_GENERIC
) {
throw new \Monarc\Core\Exception\Exception(
'You can not make this change. '.
'The level of integrity between '.
'the model and its objects would corrupt',
412
);
}
}
}
Expand All @@ -214,7 +234,11 @@ public function verifyBeforeUpdate($model, $data)
if (!empty($objects)) {
foreach ($objects as $o) {
if ($o->get('mode') == $modeObject) {
throw new \Monarc\Core\Exception\Exception('You can not make this change. The level of integrity between the model and its objects would corrupt', 412);
throw new \Monarc\Core\Exception\Exception(
'You can not make this change. '.
'The level of integrity between the model and its objects would corrupt',
412
);
}
}
}
Expand Down

0 comments on commit 34c2ed3

Please sign in to comment.