src/Helper/PageHelper.php
public function makeTranslationCopy(PageInterface $page, $locale)
    {
        $pageClass = $this->pageManager->getClassName();
        /** @var PageInterface $pageCopy */
        $pageCopy = new $pageClass();

        $pageCopy->setPageName($page->getPageName());
        $pageCopy->setMetaTitle($page->getMetaTitle());
        $pageCopy->setUrl($page->getUrl());
        $pageCopy->setMetaKeyword($page->getMetaKeyword());
        $pageCopy->setMetaDescription($page->getMetaDescription());
        $pageCopy->setActiveFrom($page->getActiveFrom());
        $pageCopy->setIsHome($page->getIsHome());
        $pageCopy->setLocale($locale);
        $pageCopy->setTemplateName($page->getTemplateName());
        $pageCopy->setOriginal($page);

        $layoutBlocks = $page->getLayoutBlock();
	    $om = $this->registry->getManager();

        foreach ($layoutBlocks as $layoutBlock) {

            /** @var $newLayoutBlock \Networking\InitCmsBundle\Model\LayoutBlockInterface */
            $newLayoutBlock = clone $layoutBlock;


            $content = $om->getRepository($newLayoutBlock->getClassType())->find(
                $newLayoutBlock->getObjectId()
            );
            $newContent = clone $content;

            $om->persist($newContent);
            $om->flush();

            $newLayoutBlock->setObjectId($newContent->getId());
            $newLayoutBlock->setPage($pageCopy);

            $om->persist($newLayoutBlock);
        }

	    $om->persist($pageCopy);

        $om->flush();

        return $pageCopy;
    }
public function makeTranslationCopy(PageInterface $page, $locale)
    {
        $pageClass = $this->pageManager->getClassName();
        /** @var PageInterface $pageCopy */
        $pageCopy = new $pageClass();

        $pageCopy->setPageName($page->getPageName());
        $pageCopy->setMetaTitle($page->getMetaTitle());
        $pageCopy->setUrl($page->getUrl());
        $pageCopy->setMetaKeyword($page->getMetaKeyword());
        $pageCopy->setMetaDescription($page->getMetaDescription());
        $pageCopy->setActiveFrom($page->getActiveFrom());
        $pageCopy->setIsHome($page->getIsHome());
        $pageCopy->setLocale($locale);
        $pageCopy->setTemplateName($page->getTemplateName());
        $pageCopy->setOriginal($page);

        $layoutBlocks = $page->getLayoutBlock();
	    $om = $this->registry->getManager();

        foreach ($layoutBlocks as $layoutBlock) {

            /** @var $newLayoutBlock \Networking\InitCmsBundle\Model\LayoutBlockInterface */
            $newLayoutBlock = clone $layoutBlock;


            $content = $om->getRepository($newLayoutBlock->getClassType())->find(
                $newLayoutBlock->getObjectId()
            );
            $newContent = clone $content;

            $om->persist($newContent);
            $om->flush();

            $newLayoutBlock->setObjectId($newContent->getId());
            $newLayoutBlock->setPage($pageCopy);

            $om->persist($newLayoutBlock);
        }

	    $om->persist($pageCopy);

        $om->flush();

        return $pageCopy;
    }
public function makeTranslationCopy ( PageInterface $ page , $ locale ) { $ pageClass = $ this -> pageManager -> getClassName ( ) ; /** @var PageInterface $pageCopy */ $ pageCopy = new $ pageClass ( ) ; $ pageCopy -> setPageName ( $ page -> getPageName ( ) ) ; $ pageCopy -> setMetaTitle ( $ page -> getMetaTitle ( ) ) ; $ pageCopy -> setUrl ( $ page -> getUrl ( ) ) ; $ pageCopy -> setMetaKeyword ( $ page -> getMetaKeyword ( ) ) ; $ pageCopy -> setMetaDescription ( $ page -> getMetaDescription ( ) ) ; $ pageCopy -> setActiveFrom ( $ page -> getActiveFrom ( ) ) ; $ pageCopy -> setIsHome ( $ page -> getIsHome ( ) ) ; $ pageCopy -> setLocale ( $ locale ) ; $ pageCopy -> setTemplateName ( $ page -> getTemplateName ( ) ) ; $ pageCopy -> setOriginal ( $ page ) ; $ layoutBlocks = $ page -> getLayoutBlock ( ) ; $ om = $ this -> registry -> getManager ( ) ; foreach ( $ layoutBlocks as $ layoutBlock ) { /** @var $newLayoutBlock \Networking\InitCmsBundle\Model\LayoutBlockInterface */ $ newLayoutBlock = clone $ layoutBlock ; $ content = $ om -> getRepository ( $ newLayoutBlock -> getClassType ( ) ) -> find ( $ newLayoutBlock -> getObjectId ( ) ) ; $ newContent = clone $ content ; $ om -> persist ( $ newContent ) ; $ om -> flush ( ) ; $ newLayoutBlock -> setObjectId ( $ newContent -> getId ( ) ) ; $ newLayoutBlock -> setPage ( $ pageCopy ) ; $ om -> persist ( $ newLayoutBlock ) ; } $ om -> persist ( $ pageCopy ) ; $ om -> flush ( ) ; return $ pageCopy ; }
create a copy of a given page object in a given locale.

@param PageInterface $page
@param $locale

@return PageInterface
create a copy of a given page object in a given locale .