Good time to all, tell me why there may be an error?
I use this code here:
$em = $this->getDoctrine()->getManager(); $do = $this->getDoctrine(); /** @var ContentBlock $ContentBlocks */ /** @var ContentBlockArchive $ContentBlocksArchive */ $ContentBlocksArchive = new ContentBlockArchive(); $ContentBlockContent = $do->getRepository(ContentBlockContent::class)->findOneBy(array('block_id'=>$ContentBlocks->getId())); $lang = $ContentBlockContent->getAliasId(); $type = $do->getRepository(ContentBlockType::class)->findOneBy(array('type'=>$ContentBlocks->getType())); $ContentBlocksArchive->setType($type); $ContentBlocksArchive->setValue($ContentBlockContent->getValue()); $ContentBlocksArchive->setLang($lang->getAlias()); $ContentBlocksArchive->setAlias($ContentBlocks->getAlias()); $ContentBlocksArchive->setName($ContentBlocks->getName()); $ContentBlocksArchive->setTimeAdd(); $em->persist($ContentBlocksArchive); $em->flush(); When it works, an error occurs:
A new entity was found through the relationship 'App\Entity\ContentBlockContent#block_id' that was not configured to cascade persist operations for entity: App\Entity\ContentBlock@0000000052faa8f9000000000c55abc4. To solve this issue: Either explicitly call EntityManager#persist() on this unknown entity or configure cascade persist this association in the mapping for example @ManyToOne(..,cascade={"persist"}). If you cannot find out which entity causes the problem implement 'App\Entity\ContentBlock#__toString()' to get a clue. Tell me why this error can occur I do not understand.