class Version implements ObjectInterface (View source)

Represents a version of a file.

Traits

Constants

UT_REPLACE_FILE

Update type: file replaced.

UT_TITLE

Update type: title updated.

UT_DESCRIPTION

Update type: description updated.

UT_TAGS

Update type: tags modified.

UT_EXTENDED_ATTRIBUTE

Update type: extended attributes changed.

UT_CONTENTS

Update type: contents changed.

UT_RENAME

Update type: file version renamed.

Properties

protected File $file

The associated File instance.

protected int $fvID

The progressive file version identifier.

protected string $fvFilename

The name of the file.

protected string $fvPrefix

The path prefix used to store the file in the file system.

protected DateTime $fvDateAdded

The date/time when the file version has been added.

protected DateTime $fvActivateDateTime

The date/time when the file version has been approved.

protected bool $fvIsApproved

Is this version the approved one for the associated file?

protected int $fvAuthorUID

The ID of the user that created the file version.

protected int $fvApproverUID

The ID of the user that approved the file version.

protected int $fvSize

The size (in bytes) of the file version.

protected string|null $fvTitle

The title of the file version.

protected string|null $fvDescription

The description of the file version.

protected string|null $fvExtension

The extension of the file version.

protected string|null $fvTags

The tags assigned to the file version (separated by a newline character - '\n').

protected int $fvType

The type of the file version.

protected bool $fvHasListingThumbnail

Does this file version has a thumbnail to be used for file listing?

protected bool $fvHasDetailThumbnail

Does this file version has a thumbnail to be used used for details?

private ImageInterface|false|null $imagineImage

The currently loaded Image instance.

Methods

getAttributeValueObject(AttributeKeyInterface|string $ak, bool $createIfNotExists = false)

No description

getAttribute($ak, $mode = false)

No description

Value
getAttributeValue($ak)

No description

clearAttribute($ak, bool $doReindexImmediately = true)

No description

Value
setAttribute($ak, mixed $value, bool $doReindexImmediately = true)

Sets the attribute of a user info object to the specified value, and saves it in the database.

__construct()

Initialize the instance.

static Version
add(File $file, string $filename, string $prefix, array $data = [])

Add a new file version.

static string
cleanTags(string $tagsStr)

Normalize the tags separator, remove empty tags.

setFile(File $file)

Set the associated File instance.

getFile()

Get the associated File instance.

int
getFileID()

Get the ID of the associated file instance.

string
getFileUUID()

Get the ID of the associated file instance.

bool
hasFileUUID()

No description

setFileVersionID(int $fvID)

Set the progressive file version identifier.

int
getFileVersionID()

Get the progressive file version identifier.

rename(string $filename)

Rename the file.

updateFile(string $filename, string $prefix)

Update the filename and the path prefix of the file.

setFilename(string $filename)

Set the name of the file.

string
getFileName()

Get the name of the file.

string
getPrefix()

Get the path prefix used to store the file in the file system.

getDateAdded()

Get the date/time when the file version has been added.

DateTime|null
getActivateDateTime()

Get the date/time when the file version has been activated (or NULL if the file version is not approved).

approve()

Mark this file version as approved (and disapprove all the other versions of the file).

deny()

Mark this file version as not approved.

bool
isApproved()

Is this version the approved one for the associated file?

int
getAuthorUserID()

Get the ID of the user that created the file version.

string
getAuthorName()

Get the username of the user that created the file version (or "Unknown").

int
getApproverUserID()

Get the ID of the user that approved the file version.

string
getApproverName()

Get the username of the user that approved the file version (or "Unknown").

int
getFullSize()

Get the file size of the file (in bytes).

string
getSize()

Get the formatted file size.

updateTitle(string $title)

Update the title of the file.

null|string
getTitle()

Get the title of the file version.

updateDescription(string $descr)

Update the description of the file.

null|string
getDescription()

Get the description of the file version.

null|string
getExtension()

Get the extension of the file version.

updateTags(string $tags)

Update the tags associated to the file.

string[]
getTagsList()

Get the tags assigned to the file version (as a list of strings).

null|string
getTags()

Get the tags assigned to the file version (one tag per line - lines are separated by '\n').

string|false
getMimeType()

Get the mime type of the file if known.

getTypeObject()

Get the type of the file.

string
getType()

Get the name of the file type.

string
getDisplayType()

Get the localized name of the file type.

string
getGenericTypeText($includeExtension = false)

Get the localized name of the generic category type.

logVersionUpdate(int $updateTypeID, int $updateTypeAttributeID = 0)

Log updates to files.

string[]
getVersionLogComments()

Get an array containing human-readable descriptions of everything that happened to this file version.

string|null
getRelativePath()

Get the path to the file relative to the webroot (may not exist).

string|null
getURL()

Get an URL that points to the file on disk (if not available, you'll get the result of the getDownloadURL method).

getFileStorageLocationConfiguration()

Get File Storage Location Configuration object of this file.

bool
hasPublicURL()

If the file storage location of this file has public URL or not.

URLInterface
getDownloadURL()

Get an URL that can be used to download the file.

URLInterface
getForceDownloadURL()

Get an URL that can be used to download the file (it will force the download of all file types, even if the browser can display them).

buildForceDownloadResponse()

Get a Response instance that will force the browser to download the file, even if the browser can display it.

bool
canView()

Check if there is a viewer for the type of the file.

bool
canEdit()

Check if there is an editor for the type of the file.

duplicate()

Create a new (unapproved) copy of this file version.

duplicateUnderlyingFile()

Duplicate the underlying file and assign its new position to this instance.

delete(bool $deleteFilesAndThumbnails = false)

Delete this version of the file.

File
getFileResource()

Get an abstract object to work with the actual file resource (note: this is NOT a concrete5 File object).

updateContents(string $contents, bool $rescanThumbnails = true)

Update the contents of the file.

string|null
getFileContents()

Get the contents of the file.

null|int
refreshAttributes(bool $rescanThumbnails = true)

Rescan all the attributes of this file version.

getAttributes()

Get the list of attributes associated to this file version.

ImageInterface|null
getImagineImage()

Get an \Imagine\Image\ImageInterface representing the image.

bool
hasImagineImage()

Does the \Imagine\Image\ImageInterface instance have already been loaded?

releaseImagineImage()

Unload the loaded Image instance.

bool
refreshThumbnails(bool $deleteExistingThumbnails)

Create missing thumbnails (or re-create all the thumbnails).

generateThumbnail(Version $type)

Generate a thumbnail for a specific thumbnail type version.

importThumbnail(Version $version, string $path)

Import an existing file as a thumbnail type version.

string|null
getThumbnailURL(Version|string $type)

Get the URL of a thumbnail type.

getThumbnails()

Get the list of all the thumbnails.

string
getDetailThumbnailImage()

Get the HTML that renders the thumbnail for the details (a generic type icon if the thumbnail does not exist).

string
getListingThumbnailImage()

Get the HTML that renders the thumbnail for the file listing (a generic type icon if the thumbnail does not exist).

deleteThumbnail(Version|string $type)

Delete the thumbnail for a specific thumbnail type version.

updateThumbnailStorageLocation(Version|string $type, StorageLocation $location)

Move the thumbnail of a specific thumbnail type version to a new storage location.

duplicateUnderlyingThumbnailFiles(Version|string $type, Version $source)

Copy the thumbnail of a specific thumbnail type version from another file version (useful for instance when duplicating a file).

getJSONObject()

Get a representation of this Version instance that's easily serializable.

forceDownload() deprecated

No description

bool
hasThumbnail(int $level) deprecated

No description

bool
rescanThumbnails() deprecated

No description

save(bool $flush = true)

Save the instance changes.

Details

CategoryInterface getObjectAttributeCategory()

AttributeValueInterface|null getAttributeValueObject(AttributeKeyInterface|string $ak, bool $createIfNotExists = false)

No description

Parameters

AttributeKeyInterface|string $ak

An attribute key instance (or its handle)

bool $createIfNotExists

Shall the generic attribute value be created if it does not already exist?

Return Value

AttributeValueInterface|null

See also

ObjectInterface::getAttributeValueObject

getAttribute($ak, $mode = false)

No description

Parameters

$ak
$mode

Value getAttributeValue($ak)

No description

Parameters

$ak

Return Value

Value

clearAttribute($ak, bool $doReindexImmediately = true)

No description

Parameters

$ak
bool $doReindexImmediately

Value setAttribute($ak, mixed $value, bool $doReindexImmediately = true)

Sets the attribute of a user info object to the specified value, and saves it in the database.

Parameters

$ak
mixed $value
bool $doReindexImmediately

Return Value

Value

__construct()

Initialize the instance.

static Version add(File $file, string $filename, string $prefix, array $data = [])

Add a new file version.

You should call refreshAttributes in order to update the size, extension, type and other attributes.

Parameters

File $file

the File instance associated to this version

string $filename

The name of the file

string $prefix

the path prefix used to store the file in the file system

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 Value

Version

static string cleanTags(string $tagsStr)

Normalize the tags separator, remove empty tags.

Parameters

string $tagsStr

The list of tags, delimited by '\n', '\r' or ','

Return Value

string

setFile(File $file)

Set the associated File instance.

Parameters

File $file

File getFile()

Get the associated File instance.

Return Value

File

int getFileID()

Get the ID of the associated file instance.

Return Value

int

string getFileUUID()

Get the ID of the associated file instance.

Return Value

string

bool hasFileUUID()

No description

Return Value

bool

setFileVersionID(int $fvID)

Set the progressive file version identifier.

Parameters

int $fvID

int getFileVersionID()

Get the progressive file version identifier.

Return Value

int

rename(string $filename)

Rename the file.

Parameters

string $filename

updateFile(string $filename, string $prefix)

Update the filename and the path prefix of the file.

Parameters

string $filename

The new name of file

string $prefix

The new path prefix

setFilename(string $filename)

Set the name of the file.

Parameters

string $filename

string getFileName()

Get the name of the file.

Return Value

string

string getPrefix()

Get the path prefix used to store the file in the file system.

Return Value

string

DateTime getDateAdded()

Get the date/time when the file version has been added.

Return Value

DateTime

DateTime|null getActivateDateTime()

Get the date/time when the file version has been activated (or NULL if the file version is not approved).

Return Value

DateTime|null

approve()

Mark this file version as approved (and disapprove all the other versions of the file).

The currently logged in user (if any) will be stored as the approver.

deny()

Mark this file version as not approved.

bool isApproved()

Is this version the approved one for the associated file?

Return Value

bool

int getAuthorUserID()

Get the ID of the user that created the file version.

Return Value

int

string getAuthorName()

Get the username of the user that created the file version (or "Unknown").

Return Value

string

int getApproverUserID()

Get the ID of the user that approved the file version.

Return Value

int

string getApproverName()

Get the username of the user that approved the file version (or "Unknown").

Return Value

string

int getFullSize()

Get the file size of the file (in bytes).

Return Value

int

string getSize()

Get the formatted file size.

Return Value

string

Examples

123 KB

updateTitle(string $title)

Update the title of the file.

Parameters

string $title

null|string getTitle()

Get the title of the file version.

Return Value

null|string

updateDescription(string $descr)

Update the description of the file.

Parameters

string $descr

null|string getDescription()

Get the description of the file version.

Return Value

null|string

null|string getExtension()

Get the extension of the file version.

Return Value

null|string

updateTags(string $tags)

Update the tags associated to the file.

Parameters

string $tags

List of tags separated by newlines and/or commas

string[] getTagsList()

Get the tags assigned to the file version (as a list of strings).

Return Value

string[]

null|string getTags()

Get the tags assigned to the file version (one tag per line - lines are separated by '\n').

Return Value

null|string

string|false getMimeType()

Get the mime type of the file if known.

Return Value

string|false

Type getTypeObject()

Get the type of the file.

Return Value

Type

string getType()

Get the name of the file type.

Return Value

string

string getDisplayType()

Get the localized name of the file type.

Return Value

string

string getGenericTypeText($includeExtension = false)

Get the localized name of the generic category type.

Parameters

$includeExtension

Return Value

string

logVersionUpdate(int $updateTypeID, int $updateTypeAttributeID = 0)

Log updates to files.

Parameters

int $updateTypeID

One of the Version::UT_... constants

int $updateTypeAttributeID

the ID of the attribute that has been updated (if any - useful when $updateTypeID is UT_EXTENDED_ATTRIBUTE)

string[] getVersionLogComments()

Get an array containing human-readable descriptions of everything that happened to this file version.

Return Value

string[]

string|null getRelativePath()

Get the path to the file relative to the webroot (may not exist).

Return NULL if the file storage location is invalid. If the storage location does not support relative paths, you'll get the URL to the file (or the download URL if the file is not directly accessible).

Return Value

string|null

Examples

/application/files/0000/0000/0000/file.png

string|null getURL()

Get an URL that points to the file on disk (if not available, you'll get the result of the getDownloadURL method).

Return NULL if the file storage location is invalid. If the file is not directly accessible, you'll get the download URL.

Return Value

string|null

protected ConfigurationInterface|null getFileStorageLocationConfiguration()

Get File Storage Location Configuration object of this file.

Return Value

ConfigurationInterface|null

bool hasPublicURL()

If the file storage location of this file has public URL or not.

Return Value

bool

URLInterface getDownloadURL()

Get an URL that can be used to download the file.

This passes through the download_file single page.

Return Value

URLInterface

URLInterface getForceDownloadURL()

Get an URL that can be used to download the file (it will force the download of all file types, even if the browser can display them).

Return Value

URLInterface

Response buildForceDownloadResponse()

Get a Response instance that will force the browser to download the file, even if the browser can display it.

Return Value

Response

bool canView()

Check if there is a viewer for the type of the file.

Return Value

bool

bool canEdit()

Check if there is an editor for the type of the file.

Return Value

bool

Version duplicate()

Create a new (unapproved) copy of this file version.

The new Version instance will have the current user as the author (if available), and a new version ID.

Return Value

Version

duplicateUnderlyingFile()

Duplicate the underlying file and assign its new position to this instance.

delete(bool $deleteFilesAndThumbnails = false)

Delete this version of the file.

Parameters

bool $deleteFilesAndThumbnails

should we delete the actual file and the thumbnails?

File getFileResource()

Get an abstract object to work with the actual file resource (note: this is NOT a concrete5 File object).

Return Value

File

Exceptions

FileNotFoundException

updateContents(string $contents, bool $rescanThumbnails = true)

Update the contents of the file.

Parameters

string $contents

The new content of the file

bool $rescanThumbnails

Should thumbnails be rescanned as well?

string|null getFileContents()

Get the contents of the file.

Return Value

string|null

return NULL if the actual file does not exist or can't be read

null|int refreshAttributes(bool $rescanThumbnails = true)

Rescan all the attributes of this file version.

This will run any type-based import routines, and store those attributes, generate thumbnails, etc...

Parameters

bool $rescanThumbnails

Should thumbnails be rescanned as well?

Return Value

null|int

Return one of the \Concrete\Core\File\Importer::E_... constants in case of errors, NULL otherwise.

FileValue[] getAttributes()

Get the list of attributes associated to this file version.

Return Value

FileValue[]

ImageInterface|null getImagineImage()

Get an \Imagine\Image\ImageInterface representing the image.

Return Value

ImageInterface|null

return NULL if the image coulnd't be read, an ImageInterface otherwise

bool hasImagineImage()

Does the \Imagine\Image\ImageInterface instance have already been loaded?

Return Value

bool

releaseImagineImage()

Unload the loaded Image instance.

bool refreshThumbnails(bool $deleteExistingThumbnails)

Create missing thumbnails (or re-create all the thumbnails).

Parameters

bool $deleteExistingThumbnails

Set to true to delete existing thumbnails (they will be re-created from scratch)

Return Value

bool

return true on success, false on failure (file is not an image, problems during image processing, ...)

generateThumbnail(Version $type)

Generate a thumbnail for a specific thumbnail type version.

Parameters

Version $type

importThumbnail(Version $version, string $path)

Import an existing file as a thumbnail type version.

Parameters

Version $version
string $path

string|null getThumbnailURL(Version|string $type)

Get the URL of a thumbnail type.

If the thumbnail is smaller than the image (or if the file does not satisfy the Conditional Thumbnail criterias) you'll get the URL of the image itself.

Please remark that the path is resolved using the default core path resolver: avoid using this method when you have access to the resolver instance.

Parameters

Version|string $type

the thumbnail type version (or its handle)

Return Value

string|null

return NULL if the thumbnail does not exist and the file storage location is invalid

Examples

/application/files/thumbnails/file_manager_listing/0000/0000/0000/file.png

Thumbnail[] getThumbnails()

Get the list of all the thumbnails.

Return Value

Thumbnail[]

Exceptions

InvalidDimensionException

string getDetailThumbnailImage()

Get the HTML that renders the thumbnail for the details (a generic type icon if the thumbnail does not exist).

Return the thumbnail for an image or a generic type icon for a file.

Return Value

string

string getListingThumbnailImage()

Get the HTML that renders the thumbnail for the file listing (a generic type icon if the thumbnail does not exist).

Return Value

string

deleteThumbnail(Version|string $type)

Delete the thumbnail for a specific thumbnail type version.

Parameters

Version|string $type

the thumbnail type version (or its handle)

updateThumbnailStorageLocation(Version|string $type, StorageLocation $location)

Move the thumbnail of a specific thumbnail type version to a new storage location.

Parameters

Version|string $type

the thumbnail type version (or its handle)

StorageLocation $location

The destination storage location

duplicateUnderlyingThumbnailFiles(Version|string $type, Version $source)

Copy the thumbnail of a specific thumbnail type version from another file version (useful for instance when duplicating a file).

Parameters

Version|string $type

the thumbnail type version (or its handle)

Version $source

The File Version instance to copy the thumbnail from

stdClass getJSONObject()

Get a representation of this Version instance that's easily serializable.

Return Value

stdClass

A \stdClass instance with all the information about a file (including permissions)

forceDownload() deprecated

deprecated Use buildForceDownloadResponse

No description

bool hasThumbnail(int $level) deprecated

deprecated

No description

Parameters

int $level

Return Value

bool

bool rescanThumbnails() deprecated

deprecated use refreshThumbnails(true) instead

No description

Return Value

bool

protected save(bool $flush = true)

Save the instance changes.

Parameters

bool $flush

Flush the EM cache?