concrete/src/Page/Cloner.php
public function cloneBlock(Block $block, Collection $destinationCollection)
    {
        $bID = $block->getBlockID();
        $aHandle = $block->getAreaHandle();
        $toID = $destinationCollection->getCollectionID();
        $toCVID = $destinationCollection->getVersionID();
        $already = $this->connection->fetchColumn(
            'select bID from CollectionVersionBlocks where cID = ? and cvID = ? and bID = ? and arHandle = ? limit 1',
            [$toID, $toCVID, $bID, $aHandle]
        );
        if ($already !== false) {
            return false;
        }
        $newBlockDisplayOrder = (int) $destinationCollection->getCollectionAreaDisplayOrder($aHandle);
        $sourceCollection = $block->getBlockCollectionID() ? $block->getBlockCollectionObject() : null;
        if ($sourceCollection) {
            $this->copyBlocks(
                [$sourceCollection->getCollectionID(), $destinationCollection->getCollectionID()],
                [$sourceCollection->getVersionID(), $destinationCollection->getVersionID()],
                [$bID, $bID],
                $newBlockDisplayOrder
            );
        } else {
            $this->connection->insert(
                'CollectionVersionBlocks',
                [
                    'cID' => $toID,
                    'cvID' => $toCVID,
                    'bID' => $bID,
                    'arHandle' => $aHandle,
                    'cbRelationID' => $block->getBlockRelationID(),
                    'cbDisplayOrder' => $newBlockDisplayOrder,
                    'isOriginal' => 0,
                    'cbOverrideAreaPermissions' => $block->overrideAreaPermissions(),
                    'cbOverrideBlockTypeCacheSettings' => $block->overrideBlockTypeCacheSettings(),
                    'cbOverrideBlockTypeContainerSettings' => $block->overrideBlockTypeContainerSettings(),
                    'cbEnableBlockContainer' => $block->enableBlockContainer() ? 1 : 0,
                ]
            );
        }

        return true;
    }
public function cloneBlock(Block $block, Collection $destinationCollection)
    {
        $bID = $block->getBlockID();
        $aHandle = $block->getAreaHandle();
        $toID = $destinationCollection->getCollectionID();
        $toCVID = $destinationCollection->getVersionID();
        $already = $this->connection->fetchColumn(
            'select bID from CollectionVersionBlocks where cID = ? and cvID = ? and bID = ? and arHandle = ? limit 1',
            [$toID, $toCVID, $bID, $aHandle]
        );
        if ($already !== false) {
            return false;
        }
        $newBlockDisplayOrder = (int) $destinationCollection->getCollectionAreaDisplayOrder($aHandle);
        $sourceCollection = $block->getBlockCollectionID() ? $block->getBlockCollectionObject() : null;
        if ($sourceCollection) {
            $this->copyBlocks(
                [$sourceCollection->getCollectionID(), $destinationCollection->getCollectionID()],
                [$sourceCollection->getVersionID(), $destinationCollection->getVersionID()],
                [$bID, $bID],
                $newBlockDisplayOrder
            );
        } else {
            $this->connection->insert(
                'CollectionVersionBlocks',
                [
                    'cID' => $toID,
                    'cvID' => $toCVID,
                    'bID' => $bID,
                    'arHandle' => $aHandle,
                    'cbRelationID' => $block->getBlockRelationID(),
                    'cbDisplayOrder' => $newBlockDisplayOrder,
                    'isOriginal' => 0,
                    'cbOverrideAreaPermissions' => $block->overrideAreaPermissions(),
                    'cbOverrideBlockTypeCacheSettings' => $block->overrideBlockTypeCacheSettings(),
                    'cbOverrideBlockTypeContainerSettings' => $block->overrideBlockTypeContainerSettings(),
                    'cbEnableBlockContainer' => $block->enableBlockContainer() ? 1 : 0,
                ]
            );
        }

        return true;
    }
public function cloneBlock ( Block $ block , Collection $ destinationCollection ) { $ bID = $ block -> getBlockID ( ) ; $ aHandle = $ block -> getAreaHandle ( ) ; $ toID = $ destinationCollection -> getCollectionID ( ) ; $ toCVID = $ destinationCollection -> getVersionID ( ) ; $ already = $ this -> connection -> fetchColumn ( 'select bID from CollectionVersionBlocks where cID = ? and cvID = ? and bID = ? and arHandle = ? limit 1' , [ $ toID , $ toCVID , $ bID , $ aHandle ] ) ; if ( $ already !== false ) { return false ; } $ newBlockDisplayOrder = ( int ) $ destinationCollection -> getCollectionAreaDisplayOrder ( $ aHandle ) ; $ sourceCollection = $ block -> getBlockCollectionID ( ) ? $ block -> getBlockCollectionObject ( ) : null ; if ( $ sourceCollection ) { $ this -> copyBlocks ( [ $ sourceCollection -> getCollectionID ( ) , $ destinationCollection -> getCollectionID ( ) ] , [ $ sourceCollection -> getVersionID ( ) , $ destinationCollection -> getVersionID ( ) ] , [ $ bID , $ bID ] , $ newBlockDisplayOrder ) ; } else { $ this -> connection -> insert ( 'CollectionVersionBlocks' , [ 'cID' => $ toID , 'cvID' => $ toCVID , 'bID' => $ bID , 'arHandle' => $ aHandle , 'cbRelationID' => $ block -> getBlockRelationID ( ) , 'cbDisplayOrder' => $ newBlockDisplayOrder , 'isOriginal' => 0 , 'cbOverrideAreaPermissions' => $ block -> overrideAreaPermissions ( ) , 'cbOverrideBlockTypeCacheSettings' => $ block -> overrideBlockTypeCacheSettings ( ) , 'cbOverrideBlockTypeContainerSettings' => $ block -> overrideBlockTypeContainerSettings ( ) , 'cbEnableBlockContainer' => $ block -> enableBlockContainer ( ) ? 1 : 0 , ] ) ; } return true ; }
Create an alias of a block to another collection.

@param \Concrete\Core\Block\Block $block
@param \Concrete\Core\Page\Collection\Collection $destinationCollection

@return bool returns FALSE if $block is not cloned because it's already present in $destinationCollection, TRUE otherwise
Create an alias of a block to another collection .