concrete/src/Page/Cloner.php
public function cloneCollection(Collection $c, ClonerOptions $options)
    {
        $cDate = $this->dateHelper->getOverridableNow();
        $this->connection->insert('Collections', [
            'cDateAdded' => $cDate,
            'cDateModified' => $cDate,
            'cHandle' => $c->getCollectionHandle(),
        ]);
        $cID = $c->getCollectionID();
        $newCID = $this->connection->lastInsertId();
        $rs = $this->connection->executeQuery('select * from CollectionVersions where cID = ? order by cvDateCreated asc', [$cID]);
        while (($row = $rs->fetch(PDO::FETCH_ASSOC)) !== false) {
            $cDate = date('Y-m-d H:i:s', strtotime($cDate) + 1);
            $this->connection->insert('CollectionVersions', [
                'cID' => $newCID,
                'cvID' => $row['cvID'],
                'cvName' => $row['cvName'],
                'cvHandle' => $row['cvHandle'],
                'cvDescription' => $row['cvDescription'],
                'cvDatePublic' => $row['cvDatePublic'],
                'cvDateCreated' => $cDate,
                'cvComments' => $row['cvComments'],
                'cvAuthorUID' => $options->keepOriginalAuthor() ? $row['cvAuthorUID'] : $options->getCurrentUser()->getUserID(),
                'cvIsApproved' => $options->forceUnapproved() ? 0 : $row['cvIsApproved'],
                'pThemeID' => $row['pThemeID'],
                'pTemplateID' => $row['pTemplateID'],
            ]);
        }
        $this->copyData($options, [$cID, $newCID]);

        return Collection::getByID($newCID);
    }
public function cloneCollection(Collection $c, ClonerOptions $options)
    {
        $cDate = $this->dateHelper->getOverridableNow();
        $this->connection->insert('Collections', [
            'cDateAdded' => $cDate,
            'cDateModified' => $cDate,
            'cHandle' => $c->getCollectionHandle(),
        ]);
        $cID = $c->getCollectionID();
        $newCID = $this->connection->lastInsertId();
        $rs = $this->connection->executeQuery('select * from CollectionVersions where cID = ? order by cvDateCreated asc', [$cID]);
        while (($row = $rs->fetch(PDO::FETCH_ASSOC)) !== false) {
            $cDate = date('Y-m-d H:i:s', strtotime($cDate) + 1);
            $this->connection->insert('CollectionVersions', [
                'cID' => $newCID,
                'cvID' => $row['cvID'],
                'cvName' => $row['cvName'],
                'cvHandle' => $row['cvHandle'],
                'cvDescription' => $row['cvDescription'],
                'cvDatePublic' => $row['cvDatePublic'],
                'cvDateCreated' => $cDate,
                'cvComments' => $row['cvComments'],
                'cvAuthorUID' => $options->keepOriginalAuthor() ? $row['cvAuthorUID'] : $options->getCurrentUser()->getUserID(),
                'cvIsApproved' => $options->forceUnapproved() ? 0 : $row['cvIsApproved'],
                'pThemeID' => $row['pThemeID'],
                'pTemplateID' => $row['pTemplateID'],
            ]);
        }
        $this->copyData($options, [$cID, $newCID]);

        return Collection::getByID($newCID);
    }
public function cloneCollection ( Collection $ c , ClonerOptions $ options ) { $ cDate = $ this -> dateHelper -> getOverridableNow ( ) ; $ this -> connection -> insert ( 'Collections' , [ 'cDateAdded' => $ cDate , 'cDateModified' => $ cDate , 'cHandle' => $ c -> getCollectionHandle ( ) , ] ) ; $ cID = $ c -> getCollectionID ( ) ; $ newCID = $ this -> connection -> lastInsertId ( ) ; $ rs = $ this -> connection -> executeQuery ( 'select * from CollectionVersions where cID = ? order by cvDateCreated asc' , [ $ cID ] ) ; while ( ( $ row = $ rs -> fetch ( PDO :: FETCH_ASSOC ) ) !== false ) { $ cDate = date ( 'Y-m-d H:i:s' , strtotime ( $ cDate ) + 1 ) ; $ this -> connection -> insert ( 'CollectionVersions' , [ 'cID' => $ newCID , 'cvID' => $ row [ 'cvID' ] , 'cvName' => $ row [ 'cvName' ] , 'cvHandle' => $ row [ 'cvHandle' ] , 'cvDescription' => $ row [ 'cvDescription' ] , 'cvDatePublic' => $ row [ 'cvDatePublic' ] , 'cvDateCreated' => $ cDate , 'cvComments' => $ row [ 'cvComments' ] , 'cvAuthorUID' => $ options -> keepOriginalAuthor ( ) ? $ row [ 'cvAuthorUID' ] : $ options -> getCurrentUser ( ) -> getUserID ( ) , 'cvIsApproved' => $ options -> forceUnapproved ( ) ? 0 : $ row [ 'cvIsApproved' ] , 'pThemeID' => $ row [ 'pThemeID' ] , 'pTemplateID' => $ row [ 'pTemplateID' ] , ] ) ; } $ this -> copyData ( $ options , [ $ cID , $ newCID ] ) ; return Collection :: getByID ( $ newCID ) ; }
Create a clone of a collection, and all its versions, contents and attributes.

@param \Concrete\Core\Page\Collection\Collection $c the collection to be cloned
@param \Concrete\Core\Page\ClonerOptions $options the options for the cloning process

@return \Concrete\Core\Page\Collection\Collection
Create a clone of a collection and all its versions contents and attributes .