src/Versioned.php
public function copyVersionToStage($fromStage, $toStage, $createNewVersion = true)
    {
        // Disallow $createNewVersion = false
        if (!$createNewVersion) {
            Deprecation::notice('5.0', 'copyVersionToStage no longer allows $createNewVersion to be false');
            $createNewVersion = true;
        }
        $owner = $this->owner;
        $owner->invokeWithExtensions('onBeforeVersionedPublish', $fromStage, $toStage, $createNewVersion);

        // Get at specific version
        $from = $this->getAtVersion($fromStage);
        if (!$from) {
            $baseClass = $owner->baseClass();
            throw new InvalidArgumentException("Can't find {$baseClass}#{$owner->ID} in stage {$fromStage}");
        }

        $from->writeToStage($toStage);
        $owner->invokeWithExtensions('onAfterVersionedPublish', $fromStage, $toStage, $createNewVersion);
    }
public function copyVersionToStage($fromStage, $toStage, $createNewVersion = true)
    {
        // Disallow $createNewVersion = false
        if (!$createNewVersion) {
            Deprecation::notice('5.0', 'copyVersionToStage no longer allows $createNewVersion to be false');
            $createNewVersion = true;
        }
        $owner = $this->owner;
        $owner->invokeWithExtensions('onBeforeVersionedPublish', $fromStage, $toStage, $createNewVersion);

        // Get at specific version
        $from = $this->getAtVersion($fromStage);
        if (!$from) {
            $baseClass = $owner->baseClass();
            throw new InvalidArgumentException("Can't find {$baseClass}#{$owner->ID} in stage {$fromStage}");
        }

        $from->writeToStage($toStage);
        $owner->invokeWithExtensions('onAfterVersionedPublish', $fromStage, $toStage, $createNewVersion);
    }
public function copyVersionToStage ( $ fromStage , $ toStage , $ createNewVersion = true ) { // Disallow $createNewVersion = false if ( ! $ createNewVersion ) { Deprecation :: notice ( '5.0' , 'copyVersionToStage no longer allows $createNewVersion to be false' ) ; $ createNewVersion = true ; } $ owner = $ this -> owner ; $ owner -> invokeWithExtensions ( 'onBeforeVersionedPublish' , $ fromStage , $ toStage , $ createNewVersion ) ; // Get at specific version $ from = $ this -> getAtVersion ( $ fromStage ) ; if ( ! $ from ) { $ baseClass = $ owner -> baseClass ( ) ; throw new InvalidArgumentException ( "Can't find {$baseClass}#{$owner->ID} in stage {$fromStage}" ) ; } $ from -> writeToStage ( $ toStage ) ; $ owner -> invokeWithExtensions ( 'onAfterVersionedPublish' , $ fromStage , $ toStage , $ createNewVersion ) ; }
Move a database record from one stage to the other.

@param int|string|null $fromStage Place to copy from.  Can be either a stage name or a version number.
Null copies current object to stage
@param string $toStage Place to copy to.  Must be a stage name.
@param bool $createNewVersion [DEPRECATED] This parameter is ignored, as copying to stage should always
create a new version.
Move a database record from one stage to the other .