concrete/src/Entity/File/File.php
public function getVersionToModify($forceCreateNew = false)
    {
        $u = new User();
        $createNew = false;

        $fv = $this->getRecentVersion();
        $fav = $this->getApprovedVersion();

        // first test. Does the user ID of the most recent version match ours? If not, then we create new
        if ($u->getUserID() != $fv->getAuthorUserID()) {
            $createNew = true;
        }

        // second test. If the date the version was added is older than File::CREATE_NEW_VERSION_THRESHOLD, we create new
        $diff = time() - $fv->getDateAdded()->getTimestamp();
        if ($diff > self::CREATE_NEW_VERSION_THRESHOLD) {
            $createNew = true;
        }

        if ($forceCreateNew) {
            $createNew = true;
        }

        if ($createNew) {
            $fv2 = $fv->duplicate();

            // Are the recent and active versions the same? If so, we approve this new version we just made
            if ($fv->getFileVersionID() == $fav->getFileVersionID()) {
                $fv2->approve();
            }

            return $fv2;
        } else {
            return $fv;
        }
    }
public function getVersionToModify($forceCreateNew = false)
    {
        $u = new User();
        $createNew = false;

        $fv = $this->getRecentVersion();
        $fav = $this->getApprovedVersion();

        // first test. Does the user ID of the most recent version match ours? If not, then we create new
        if ($u->getUserID() != $fv->getAuthorUserID()) {
            $createNew = true;
        }

        // second test. If the date the version was added is older than File::CREATE_NEW_VERSION_THRESHOLD, we create new
        $diff = time() - $fv->getDateAdded()->getTimestamp();
        if ($diff > self::CREATE_NEW_VERSION_THRESHOLD) {
            $createNew = true;
        }

        if ($forceCreateNew) {
            $createNew = true;
        }

        if ($createNew) {
            $fv2 = $fv->duplicate();

            // Are the recent and active versions the same? If so, we approve this new version we just made
            if ($fv->getFileVersionID() == $fav->getFileVersionID()) {
                $fv2->approve();
            }

            return $fv2;
        } else {
            return $fv;
        }
    }
public function getVersionToModify ( $ forceCreateNew = false ) { $ u = new User ( ) ; $ createNew = false ; $ fv = $ this -> getRecentVersion ( ) ; $ fav = $ this -> getApprovedVersion ( ) ; // first test. Does the user ID of the most recent version match ours? If not, then we create new if ( $ u -> getUserID ( ) != $ fv -> getAuthorUserID ( ) ) { $ createNew = true ; } // second test. If the date the version was added is older than File::CREATE_NEW_VERSION_THRESHOLD, we create new $ diff = time ( ) - $ fv -> getDateAdded ( ) -> getTimestamp ( ) ; if ( $ diff > self :: CREATE_NEW_VERSION_THRESHOLD ) { $ createNew = true ; } if ( $ forceCreateNew ) { $ createNew = true ; } if ( $ createNew ) { $ fv2 = $ fv -> duplicate ( ) ; // Are the recent and active versions the same? If so, we approve this new version we just made if ( $ fv -> getFileVersionID ( ) == $ fav -> getFileVersionID ( ) ) { $ fv2 -> approve ( ) ; } return $ fv2 ; } else { return $ fv ; } }
Returns a file version object that is to be written to. Computes whether we can use the current most recent version, OR a new one should be created.

@param bool $forceCreateNew If we should always create a new version even if we are below the threshold

@return Version
Returns a file version object that is to be written to . Computes whether we can use the current most recent version OR a new one should be created .