fix(machine-clone) : preserve context field values when cloning a machine
All checks were successful
Auto Tag Develop / tag (push) Successful in 35s
All checks were successful
Auto Tag Develop / tag (push) Successful in 35s
Context CustomFieldValues attached to component/piece links were silently dropped from the clone response (and from any subsequent read in the same request) because the controller persisted the new CFVs without adding them to the inverse-side collection of the new link. Doctrine does not auto-sync inverse OneToMany associations, so getContextFieldValues() returned an empty collection on the freshly persisted link. Also synchronise the inverse collection in the test factory so identity-mapped entities reflect newly-created CFVs when reused by request handlers within the same test. Co-Authored-By: RuFlo <ruv@ruv.net>
This commit is contained in:
@@ -337,6 +337,7 @@ class MachineStructureController extends AbstractController
|
||||
$newValue->setMachineComponentLink($newLink);
|
||||
$newValue->setComposant($newLink->getComposant());
|
||||
$this->entityManager->persist($newValue);
|
||||
$newLink->getContextFieldValues()->add($newValue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,6 +353,7 @@ class MachineStructureController extends AbstractController
|
||||
$newValue->setMachinePieceLink($newLink);
|
||||
$newValue->setPiece($newLink->getPiece());
|
||||
$this->entityManager->persist($newValue);
|
||||
$newLink->getContextFieldValues()->add($newValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user