Skip to content

Commit

Permalink
Fixed the creation of SoaCategory in case of bulk operation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruslan Baidan committed Mar 5, 2021
1 parent 47e0041 commit a3fcbee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/Service/RolfRiskService.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Monarc\Core\Model\Table\MonarcObjectTable;
use Doctrine\ORM\Query\QueryException;
use Doctrine\ORM\Mapping\MappingException;
use Monarc\Core\Model\Table\RolfRiskTable;

/**
* Rolf Risk Service
Expand Down Expand Up @@ -99,10 +100,11 @@ public function getFilteredSpecificCount($page = 1, $limit = 25, $order = null,
public function create($data, $last = true)
{
$addedTags = [];
/** @var RolfRiskSuperClass $rolfRisk */
/** @var RolfRiskTable $rolfRiskTable */
$rolfRiskTable = $this->get('table');
$entityClass = $rolfRiskTable->getEntityClass();

/** @var RolfRiskSuperClass $rolfRisk */
$rolfRisk = new $entityClass();
$rolfRisk->setLanguage($this->getLanguage());
$rolfRisk->setDbAdapter($rolfRiskTable->getDb());
Expand Down Expand Up @@ -134,7 +136,7 @@ public function create($data, $last = true)
$this->getConnectedUser()->getFirstname() . ' ' . $this->getConnectedUser()->getLastname()
);

$opId = $this->get('table')->save($rolfRisk);
$opId = $rolfRiskTable->save($rolfRisk);

$data = [
'anr' => $data['anr'],
Expand Down
13 changes: 9 additions & 4 deletions src/Service/SoaCategoryService.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
namespace Monarc\Core\Service;

use Monarc\Core\Model\Entity\SoaCategory;
use Monarc\Core\Model\Table\SoaCategoryTable;

/**
* SoaCategory Service
Expand All @@ -23,18 +24,22 @@ class SoaCategoryService extends AbstractService

public function create($data, $last = true)
{
/** @var SoaCategory $soaCategory */
$soaCategory = $this->get('entity');

$referentialTable = $this->get('referentialTable');
$data['referential'] = $referentialTable->getEntity($data['referential']);

/** @var SoaCategoryTable $soaCategoryTable */
$soaCategoryTable = $this->get('table');
$entityClass = $soaCategoryTable->getEntityClass();
/** @var SoaCategory $soaCategory */
$soaCategory = new $entityClass();
$soaCategory->setLanguage($this->getLanguage());
$soaCategory->setDbAdapter($soaCategoryTable->getDb());
$soaCategory->exchangeArray($data);

$dependencies = property_exists($this, 'dependencies') ? $this->dependencies : [];
$this->setDependencies($soaCategory, $dependencies);

return $this->get('table')->save($soaCategory, $last);
return $soaCategoryTable->save($soaCategory, $last);
}

public function delete($id)
Expand Down

0 comments on commit a3fcbee

Please sign in to comment.