concrete/src/Entity/File/Version.php
public static function add(File $file, $filename, $prefix, $data = [])
    {
        $data += [
            'uID' => 0,
            'fvTitle' => '',
            'fvDescription' => '',
            'fvTags' => '',
            'fvIsApproved' => true,
        ];

        $app = Application::getFacadeApplication();
        $em = $app->make(EntityManagerInterface::class);
        $dh = $app->make('date');

        $date = new DateTime($dh->getOverridableNow());
        $uID = (int) $data['uID'];
        if ($uID < 1) {
            if (User::isLoggedIn()) {
                $uID = (int) (new User())->getUserID();
            } else {
                $uID = 0;
            }
        }

        $fv = new static();
        $fv->file = $file;
        $fv->fvID = 1;
        $fv->fvFilename = (string) $filename;
        $fv->fvPrefix = $prefix;
        $fv->fvDateAdded = $date;
        $fv->fvActivateDateTime = $date;
        $fv->fvIsApproved = (bool) $data['fvIsApproved'];
        $fv->fvAuthorUID = $uID;
        $fv->fvApproverUID = $uID;
        $fv->fvTitle = (string) $data['fvTitle'];
        $fv->fvDescription = (string) $data['fvDescription'];
        $fv->fvTags = self::cleanTags((string) $data['fvTags']);
        $em->persist($fv);
        $em->flush();

        $fve = new FileVersionEvent($fv);
        $app->make(EventDispatcherInterface::class)->dispatch('on_file_version_add', $fve);

        return $fv;
    }
public static function add(File $file, $filename, $prefix, $data = [])
    {
        $data += [
            'uID' => 0,
            'fvTitle' => '',
            'fvDescription' => '',
            'fvTags' => '',
            'fvIsApproved' => true,
        ];

        $app = Application::getFacadeApplication();
        $em = $app->make(EntityManagerInterface::class);
        $dh = $app->make('date');

        $date = new DateTime($dh->getOverridableNow());
        $uID = (int) $data['uID'];
        if ($uID < 1) {
            if (User::isLoggedIn()) {
                $uID = (int) (new User())->getUserID();
            } else {
                $uID = 0;
            }
        }

        $fv = new static();
        $fv->file = $file;
        $fv->fvID = 1;
        $fv->fvFilename = (string) $filename;
        $fv->fvPrefix = $prefix;
        $fv->fvDateAdded = $date;
        $fv->fvActivateDateTime = $date;
        $fv->fvIsApproved = (bool) $data['fvIsApproved'];
        $fv->fvAuthorUID = $uID;
        $fv->fvApproverUID = $uID;
        $fv->fvTitle = (string) $data['fvTitle'];
        $fv->fvDescription = (string) $data['fvDescription'];
        $fv->fvTags = self::cleanTags((string) $data['fvTags']);
        $em->persist($fv);
        $em->flush();

        $fve = new FileVersionEvent($fv);
        $app->make(EventDispatcherInterface::class)->dispatch('on_file_version_add', $fve);

        return $fv;
    }
public static function add ( File $ file , $ filename , $ prefix , $ data = [ ] ) { $ data += [ 'uID' => 0 , 'fvTitle' => '' , 'fvDescription' => '' , 'fvTags' => '' , 'fvIsApproved' => true , ] ; $ app = Application :: getFacadeApplication ( ) ; $ em = $ app -> make ( EntityManagerInterface :: class ) ; $ dh = $ app -> make ( 'date' ) ; $ date = new DateTime ( $ dh -> getOverridableNow ( ) ) ; $ uID = ( int ) $ data [ 'uID' ] ; if ( $ uID < 1 ) { if ( User :: isLoggedIn ( ) ) { $ uID = ( int ) ( new User ( ) ) -> getUserID ( ) ; } else { $ uID = 0 ; } } $ fv = new static ( ) ; $ fv -> file = $ file ; $ fv -> fvID = 1 ; $ fv -> fvFilename = ( string ) $ filename ; $ fv -> fvPrefix = $ prefix ; $ fv -> fvDateAdded = $ date ; $ fv -> fvActivateDateTime = $ date ; $ fv -> fvIsApproved = ( bool ) $ data [ 'fvIsApproved' ] ; $ fv -> fvAuthorUID = $ uID ; $ fv -> fvApproverUID = $ uID ; $ fv -> fvTitle = ( string ) $ data [ 'fvTitle' ] ; $ fv -> fvDescription = ( string ) $ data [ 'fvDescription' ] ; $ fv -> fvTags = self :: cleanTags ( ( string ) $ data [ 'fvTags' ] ) ; $ em -> persist ( $ fv ) ; $ em -> flush ( ) ; $ fve = new FileVersionEvent ( $ fv ) ; $ app -> make ( EventDispatcherInterface :: class ) -> dispatch ( 'on_file_version_add' , $ fve ) ; return $ fv ; }
Add a new file version.
You should call refreshAttributes in order to update the size, extension, type and other attributes.

@param \Concrete\Core\Entity\File\File $file the File instance associated to this version
@param string $filename The name of the file
@param string $prefix the path prefix used to store the file in the file system
@param array $data Valid array keys are {

@var int|null $uID the ID of the user that creates the file version (if not specified or empty: we'll assume the currently user logged in user)
@var string $fvTitle the title of the file version
@var string $fvDescription the description of the file version
@var string $fvTags the tags to be assigned to the file version (separated by newlines and/or commas)
@var bool $fvIsApproved Is this version the approved one for the associated file? (default: true)
}

@return static
Add a new file version . You should call refreshAttributes in order to update the size extension type and other attributes .