plugin/website/Manager/WebsiteManager.php
public function copyWebsite(Website $orgWebsite, Website $newWebsite)
    {
        $orgRoot = $orgWebsite->getRoot();
        $orgOptions = $orgWebsite->getOptions();
        $websitePages = $this->websitePageRepository->children($orgRoot);
        array_unshift($websitePages, $orgRoot);
        $newWebsitePagesMap = [];

        foreach ($websitePages as $websitePage) {
            $newWebsitePage = new WebsitePage();
            $newWebsitePage->setWebsite($newWebsite);
            $newWebsitePage->importFromArray($websitePage->exportToArray());
            if ($websitePage->isRoot()) {
                $newWebsite->setRoot($newWebsitePage);
                $this->om->persist($newWebsite);
            } else {
                $newWebsitePageParent = $newWebsitePagesMap[$websitePage->getParent()->getId()];
                $newWebsitePage->setParent($newWebsitePageParent);
                $this->websitePageRepository->persistAsLastChildOf($newWebsitePage, $newWebsitePageParent);
            }
            if ($websitePage->getIsHomepage()) {
                $newWebsite->setHomePage($newWebsitePage);
            }

            $newWebsitePagesMap[$websitePage->getId()] = $newWebsitePage;
        }
        $this->om->flush();
        $newWebsite->getOptions()->importFromArray(
            $this->webDir,
            $orgOptions->exportToArray($this->webDir),
            $this->webDir.DIRECTORY_SEPARATOR.$orgOptions->getUploadDir()
        );

        return $newWebsite;
    }
public function copyWebsite(Website $orgWebsite, Website $newWebsite)
    {
        $orgRoot = $orgWebsite->getRoot();
        $orgOptions = $orgWebsite->getOptions();
        $websitePages = $this->websitePageRepository->children($orgRoot);
        array_unshift($websitePages, $orgRoot);
        $newWebsitePagesMap = [];

        foreach ($websitePages as $websitePage) {
            $newWebsitePage = new WebsitePage();
            $newWebsitePage->setWebsite($newWebsite);
            $newWebsitePage->importFromArray($websitePage->exportToArray());
            if ($websitePage->isRoot()) {
                $newWebsite->setRoot($newWebsitePage);
                $this->om->persist($newWebsite);
            } else {
                $newWebsitePageParent = $newWebsitePagesMap[$websitePage->getParent()->getId()];
                $newWebsitePage->setParent($newWebsitePageParent);
                $this->websitePageRepository->persistAsLastChildOf($newWebsitePage, $newWebsitePageParent);
            }
            if ($websitePage->getIsHomepage()) {
                $newWebsite->setHomePage($newWebsitePage);
            }

            $newWebsitePagesMap[$websitePage->getId()] = $newWebsitePage;
        }
        $this->om->flush();
        $newWebsite->getOptions()->importFromArray(
            $this->webDir,
            $orgOptions->exportToArray($this->webDir),
            $this->webDir.DIRECTORY_SEPARATOR.$orgOptions->getUploadDir()
        );

        return $newWebsite;
    }
public function copyWebsite ( Website $ orgWebsite , Website $ newWebsite ) { $ orgRoot = $ orgWebsite -> getRoot ( ) ; $ orgOptions = $ orgWebsite -> getOptions ( ) ; $ websitePages = $ this -> websitePageRepository -> children ( $ orgRoot ) ; array_unshift ( $ websitePages , $ orgRoot ) ; $ newWebsitePagesMap = [ ] ; foreach ( $ websitePages as $ websitePage ) { $ newWebsitePage = new WebsitePage ( ) ; $ newWebsitePage -> setWebsite ( $ newWebsite ) ; $ newWebsitePage -> importFromArray ( $ websitePage -> exportToArray ( ) ) ; if ( $ websitePage -> isRoot ( ) ) { $ newWebsite -> setRoot ( $ newWebsitePage ) ; $ this -> om -> persist ( $ newWebsite ) ; } else { $ newWebsitePageParent = $ newWebsitePagesMap [ $ websitePage -> getParent ( ) -> getId ( ) ] ; $ newWebsitePage -> setParent ( $ newWebsitePageParent ) ; $ this -> websitePageRepository -> persistAsLastChildOf ( $ newWebsitePage , $ newWebsitePageParent ) ; } if ( $ websitePage -> getIsHomepage ( ) ) { $ newWebsite -> setHomePage ( $ newWebsitePage ) ; } $ newWebsitePagesMap [ $ websitePage -> getId ( ) ] = $ newWebsitePage ; } $ this -> om -> flush ( ) ; $ newWebsite -> getOptions ( ) -> importFromArray ( $ this -> webDir , $ orgOptions -> exportToArray ( $ this -> webDir ) , $ this -> webDir . DIRECTORY_SEPARATOR . $ orgOptions -> getUploadDir ( ) ) ; return $ newWebsite ; }
Copies website to a location.

@param Website $orgWebsite

@return Website
Copies website to a location .