Skip to content

Commit

Permalink
[ResourceBundle, ProductBundle] don't use temporary entity manager fo…
Browse files Browse the repository at this point in the history
…r unit-defs
  • Loading branch information
dpfaffenbauer committed Apr 27, 2024
1 parent a1c4998 commit ba90878
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,6 @@ public function save($object, $params = [])
$productUnitDefinitions = $object->getObjectVar($this->getName());

if ($productUnitDefinitions instanceof ProductUnitDefinitionsInterface) {
$entityMerger = new EntityMerger($this->getEntityManager());
$entityMerger->merge($productUnitDefinitions);

$productUnitDefinitions->setProduct($object);

$this->getEntityManager()->persist($productUnitDefinitions);
Expand Down Expand Up @@ -407,19 +404,7 @@ public function getDataFromEditmode($data, $object = null, $params = [])
}

$errors = [];
$productUnitDefinitionsValues = null;

$unitDefinitionsEntity = null;
$unitDefinitionsId = isset($data['id']) && is_numeric($data['id']) ? $data['id'] : null;

$tempEntityManager = $this->createTempEntityManager($this->getEntityManager());
$tempStoreValuesRepository = $this->getProductUnitDefinitionsRepositoryFactory()->createNewRepository($tempEntityManager);

Assert::isInstanceOf($tempStoreValuesRepository, ProductUnitDefinitionsRepositoryInterface::class);

if ($unitDefinitionsId !== null) {
$unitDefinitionsEntity = $tempStoreValuesRepository->findOneForProduct($object);
}
$unitDefinitionsEntity = $this->getProductUnitDefinitionsRepository()->findOneForProduct($object);

$form = $this->getFormFactory()->createNamed('', ProductUnitDefinitionsType::class, $unitDefinitionsEntity);

Expand Down
11 changes: 1 addition & 10 deletions src/CoreShop/Bundle/ResourceBundle/Doctrine/ORM/EntityMerger.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,7 @@ private function doMerge($entity, array &$visited): void
$class = $this->em->getClassMetadata($entity::class);

if ($entity instanceof Proxy && !$entity->__isInitialized()) {
$id = $class->getIdentifierValues($entity);

$uwEntity = $this->em->getUnitOfWork()->tryGetById($id, $class->getName());

if ($uwEntity) {
$entity = $uwEntity;
}
else {
$entity->__load();
}
$entity->__load();
}


Expand Down

0 comments on commit ba90878

Please sign in to comment.