Answer the question
In order to leave comments, you need to log in
How to hint to Doctrine / Unit of Work that we are working with existing data after serialization?
We have an entity, we get it from the database
public function find(string $id): ?DomainEntity {
/** @var DoctrineEntity|null $entity */
$entity = $this->findOneBy(['id' => $id]);
if (true === $entity instanceof DoctrineEntity) {
$entity = $this->coverter->covertDoctrineToDomainEntity($entity);
}
return $entity;
}
$entity = $this->coverter->covertDomainEntityToDoctrine($domainEntity);
$entityManger->persist(this->coverter->covertDomainEntityToDoctrine($domainEntity);
$entityManger->clear(DoctrineEntity::class);
$entityManger->detach($doctrineEntity);
$entityManger->remove($doctrineEntity);
$this->unitOfWork->remove($entity);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question