concrete/src/Page/Cloner.php
public function cloneCollectionVersion(Version $cvSource, Collection $cDestination, ClonerOptions $options)
    {
        $cSourceID = $cvSource->getCollectionID();
        $cvSourceID = $cvSource->getVersionID();

        $cSource = Page::getByID($cSourceID, $cvSourceID);

        $cDestinationID = $cDestination->getCollectionID();
        $cvDestinationID = 1 + (int) $this->connection->fetchColumn('select max(cvID) from CollectionVersions where cID = ?', [$cDestinationID]);
        $versionComments = $options->getVersionComments();
        if ($versionComments === '') {
            $versionComments = t('New Version %s', $cvDestinationID);
        }
        if ($cSourceID == $cDestinationID) {
            $cvIsNew = 1;
            if ($cSource->getPageTypeHandle() === STACKS_PAGE_TYPE) {
                $cvIsNew = 0;
            }
        } else {
            $cvIsNew = 0;
        }

        $this->connection->insert('CollectionVersions', [
            'cID' => $cDestinationID,
            'cvID' => $cvDestinationID,
            'cvName' => $cvSource->getVersionName(),
            'cvHandle' => $cDestination->getCollectionHandle(),
            'cvDescription' => $cvSource->cvDescription,
            'cvDatePublic' => $cvSource->cvDatePublic,
            'cvDateCreated' => $this->dateHelper->getOverridableNow(),
            'cvComments' => $versionComments,
            'cvAuthorUID' => $options->keepOriginalAuthor() ? $cvSource->getVersionAuthorUserID() : $options->getCurrentUser()->getUserID(),
            'cvIsNew' => $cvIsNew,
            'pThemeID' => $cvSource->pThemeID,
            'pTemplateID' => $cvSource->pTemplateID,
            // important: cvPublishDate used to be the same for the new version as it is for the current,
            // but it made it impossible to create a version that wasn't scheduled once you scheduled a version
            // so I'm turning it off for now - AE
            'cvPublishDate' => null,
        ]);

        $this->copyData($options, [$cSourceID, $cDestinationID], [$cvSourceID, $cvDestinationID]);

        $cvDestination = Version::get($cSource, $cvDestinationID);

        $ev = new CollectionVersionEvent($cSource);
        $ev->setCollectionVersionObject($cvDestination);
        $this->eventDispatcher->dispatch('on_page_version_add', $ev);

        $cvDestination->refreshCache();

        return $cvDestination;
    }
public function cloneCollectionVersion(Version $cvSource, Collection $cDestination, ClonerOptions $options)
    {
        $cSourceID = $cvSource->getCollectionID();
        $cvSourceID = $cvSource->getVersionID();

        $cSource = Page::getByID($cSourceID, $cvSourceID);

        $cDestinationID = $cDestination->getCollectionID();
        $cvDestinationID = 1 + (int) $this->connection->fetchColumn('select max(cvID) from CollectionVersions where cID = ?', [$cDestinationID]);
        $versionComments = $options->getVersionComments();
        if ($versionComments === '') {
            $versionComments = t('New Version %s', $cvDestinationID);
        }
        if ($cSourceID == $cDestinationID) {
            $cvIsNew = 1;
            if ($cSource->getPageTypeHandle() === STACKS_PAGE_TYPE) {
                $cvIsNew = 0;
            }
        } else {
            $cvIsNew = 0;
        }

        $this->connection->insert('CollectionVersions', [
            'cID' => $cDestinationID,
            'cvID' => $cvDestinationID,
            'cvName' => $cvSource->getVersionName(),
            'cvHandle' => $cDestination->getCollectionHandle(),
            'cvDescription' => $cvSource->cvDescription,
            'cvDatePublic' => $cvSource->cvDatePublic,
            'cvDateCreated' => $this->dateHelper->getOverridableNow(),
            'cvComments' => $versionComments,
            'cvAuthorUID' => $options->keepOriginalAuthor() ? $cvSource->getVersionAuthorUserID() : $options->getCurrentUser()->getUserID(),
            'cvIsNew' => $cvIsNew,
            'pThemeID' => $cvSource->pThemeID,
            'pTemplateID' => $cvSource->pTemplateID,
            // important: cvPublishDate used to be the same for the new version as it is for the current,
            // but it made it impossible to create a version that wasn't scheduled once you scheduled a version
            // so I'm turning it off for now - AE
            'cvPublishDate' => null,
        ]);

        $this->copyData($options, [$cSourceID, $cDestinationID], [$cvSourceID, $cvDestinationID]);

        $cvDestination = Version::get($cSource, $cvDestinationID);

        $ev = new CollectionVersionEvent($cSource);
        $ev->setCollectionVersionObject($cvDestination);
        $this->eventDispatcher->dispatch('on_page_version_add', $ev);

        $cvDestination->refreshCache();

        return $cvDestination;
    }
public function cloneCollectionVersion ( Version $ cvSource , Collection $ cDestination , ClonerOptions $ options ) { $ cSourceID = $ cvSource -> getCollectionID ( ) ; $ cvSourceID = $ cvSource -> getVersionID ( ) ; $ cSource = Page :: getByID ( $ cSourceID , $ cvSourceID ) ; $ cDestinationID = $ cDestination -> getCollectionID ( ) ; $ cvDestinationID = 1 + ( int ) $ this -> connection -> fetchColumn ( 'select max(cvID) from CollectionVersions where cID = ?' , [ $ cDestinationID ] ) ; $ versionComments = $ options -> getVersionComments ( ) ; if ( $ versionComments === '' ) { $ versionComments = t ( 'New Version %s' , $ cvDestinationID ) ; } if ( $ cSourceID == $ cDestinationID ) { $ cvIsNew = 1 ; if ( $ cSource -> getPageTypeHandle ( ) === STACKS_PAGE_TYPE ) { $ cvIsNew = 0 ; } } else { $ cvIsNew = 0 ; } $ this -> connection -> insert ( 'CollectionVersions' , [ 'cID' => $ cDestinationID , 'cvID' => $ cvDestinationID , 'cvName' => $ cvSource -> getVersionName ( ) , 'cvHandle' => $ cDestination -> getCollectionHandle ( ) , 'cvDescription' => $ cvSource -> cvDescription , 'cvDatePublic' => $ cvSource -> cvDatePublic , 'cvDateCreated' => $ this -> dateHelper -> getOverridableNow ( ) , 'cvComments' => $ versionComments , 'cvAuthorUID' => $ options -> keepOriginalAuthor ( ) ? $ cvSource -> getVersionAuthorUserID ( ) : $ options -> getCurrentUser ( ) -> getUserID ( ) , 'cvIsNew' => $ cvIsNew , 'pThemeID' => $ cvSource -> pThemeID , 'pTemplateID' => $ cvSource -> pTemplateID , // important: cvPublishDate used to be the same for the new version as it is for the current, // but it made it impossible to create a version that wasn't scheduled once you scheduled a version // so I'm turning it off for now - AE 'cvPublishDate' => null , ] ) ; $ this -> copyData ( $ options , [ $ cSourceID , $ cDestinationID ] , [ $ cvSourceID , $ cvDestinationID ] ) ; $ cvDestination = Version :: get ( $ cSource , $ cvDestinationID ) ; $ ev = new CollectionVersionEvent ( $ cSource ) ; $ ev -> setCollectionVersionObject ( $ cvDestination ) ; $ this -> eventDispatcher -> dispatch ( 'on_page_version_add' , $ ev ) ; $ cvDestination -> refreshCache ( ) ; return $ cvDestination ; }
Create a copy of a collection version to another collection.

@param \Concrete\Core\Page\Collection\Version\Version $cvSource
@param \Concrete\Core\Page\Collection\Collection $cDestination
@param \Concrete\Core\Page\ClonerOptions $options the options for the cloning process

@return \Concrete\Core\Page\Collection\Version\Version
Create a copy of a collection version to another collection .