/** * @param DeepCloneAndSaveEvent $event */ public function postDeepCloneAndSave(DeepCloneAndSaveEvent $event) { $originalEntity = $event->getEntity(); if ($originalEntity instanceof Taggable) { $targetEntity = $event->getClonedEntity(); $this->em->getRepository('KunstmaanTaggingBundle:Tag')->copyTags($originalEntity, $targetEntity); } }
/** * @param DeepCloneAndSaveEvent $event */ public function onDeepCloneAndSave(DeepCloneAndSaveEvent $event) { $clonedEntity = $event->getClonedEntity(); if ($clonedEntity instanceof AbstractEntity) { $clonedEntity->setId(null); } if ($clonedEntity instanceof DeepCloneInterface) { $clonedEntity->deepClone(); } }
/** * @param DeepCloneAndSaveEvent $event */ public function postDeepCloneAndSave(DeepCloneAndSaveEvent $event) { $originalEntity = $event->getEntity(); if ($originalEntity instanceof AbstractEntity) { /* @var Seo $seo */ $seo = $this->em->getRepository('KunstmaanSeoBundle:Seo')->findFor($originalEntity); if (!is_null($seo)) { /* @var Seo $clonedSeo */ $clonedSeo = $this->cloneHelper->deepCloneAndSave($seo); $clonedSeo->setRef($event->getClonedEntity()); $this->em->persist($clonedSeo); $this->em->flush($clonedSeo); } } }
/** * @param DeepCloneAndSaveEvent $event */ public function postDeepCloneAndSave(DeepCloneAndSaveEvent $event) { $originalEntity = $event->getEntity(); if ($originalEntity instanceof HasPagePartsInterface) { $clonedEntity = $event->getClonedEntity(); $contexts = $this->pagePartReader->getPagePartContexts($originalEntity); foreach ($contexts as $context) { $this->em->getRepository('KunstmaanPagePartBundle:PagePartRef')->copyPageParts($this->em, $originalEntity, $clonedEntity, $context); } } if ($originalEntity instanceof HasPageTemplateInterface) { $clonedEntity = $event->getClonedEntity(); $newPageTemplateConfiguration = clone $this->pageTemplateConfiguratiorService->findOrCreateFor($originalEntity); $newPageTemplateConfiguration->setId(null); $newPageTemplateConfiguration->setPageId($clonedEntity->getId()); $this->em->persist($newPageTemplateConfiguration); } }