Skip to content

Commit

Permalink
Fixed the risks creation for the child objects of the anr.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruslan Baidan committed Feb 24, 2020
1 parent 40f4596 commit 0dd391f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
31 changes: 17 additions & 14 deletions src/Service/InstanceRiskOpService.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,21 +76,24 @@ public function createInstanceRisksOp($instanceId, $anrId, $object)
/** @var InstanceRiskOpTable $instanceRiskOpTable */
$instanceRiskOpTable = $this->get('table');
foreach ($instances as $instance) {
if ($instance->id != $instanceId) {
$instancesRisksOp = $instanceRiskOpTable->getEntityByFields(['instance' => $instance->id]);
foreach ($instancesRisksOp as $instanceRiskOp) {
/** @var InstanceRiskOp $newInstanceRiskOp */
$newInstanceRiskOp = clone $instanceRiskOp;
$newInstanceRiskOp->setId(null);
$newInstanceRiskOp->setInstance($currentInstance);

$newInstanceRiskOp->setCreator(
$this->getConnectedUser()->getFirstname() . ' ' . $this->getConnectedUser()->getLastname()
);

$instanceRiskOpTable->save($newInstanceRiskOp);
}
if ($instance->getId() === $instanceId) {
continue;
}

$instancesRisksOp = $instanceRiskOpTable->getEntityByFields(['instance' => $instance->id]);
foreach ($instancesRisksOp as $instanceRiskOp) {
/** @var InstanceRiskOp $newInstanceRiskOp */
$newInstanceRiskOp = clone $instanceRiskOp;
$newInstanceRiskOp->setId(null);
$newInstanceRiskOp->setInstance($currentInstance);

$newInstanceRiskOp->setCreator(
$this->getConnectedUser()->getFirstname() . ' ' . $this->getConnectedUser()->getLastname()
);

$instanceRiskOpTable->save($newInstanceRiskOp);
}

break;
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/Service/InstanceRiskService.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ public function createInstanceRisks($instanceId, $anrId, $object)
}
}
}

break;
}

break;
}
} else {
/** @var AmvTable $amvTable */
Expand Down

0 comments on commit 0dd391f

Please sign in to comment.