コード例 #1
0
 /**
  * @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);
         }
     }
 }
コード例 #2
0
 /**
  * This shouldn't be here either but it's an improvement.
  *
  * @param HasNodeInterface $page            The page
  * @param NodeTranslation  $nodeTranslation The node translation
  * @param NodeVersion      $nodeVersion     The node version
  * @param BaseUser         $user            The user
  *
  * @return mixed
  */
 public function createPublicVersion(HasNodeInterface $page, NodeTranslation $nodeTranslation, NodeVersion $nodeVersion, BaseUser $user)
 {
     $newPublicPage = $this->cloneHelper->deepCloneAndSave($page);
     $newNodeVersion = $this->em->getRepository('KunstmaanNodeBundle:NodeVersion')->createNodeVersionFor($newPublicPage, $nodeTranslation, $user, $nodeVersion);
     $newNodeVersion->setOwner($nodeVersion->getOwner())->setUpdated($nodeVersion->getUpdated())->setCreated($nodeVersion->getCreated());
     $nodeVersion->setOwner($user)->setCreated(new \DateTime())->setOrigin($newNodeVersion);
     $this->em->persist($newNodeVersion);
     $this->em->persist($nodeVersion);
     $this->em->persist($nodeTranslation);
     $this->em->flush();
     $this->eventDispatcher->dispatch(Events::CREATE_PUBLIC_VERSION, new NodeEvent($nodeTranslation->getNode(), $nodeTranslation, $nodeVersion, $newPublicPage));
     return $newNodeVersion;
 }