class File implements ObjectInterface, ObjectInterface (View source)

Constants

CREATE_NEW_VERSION_THRESHOLD

Properties

$fID
protected string|null $fUUID
$fDateAdded
$fPassword
$versions
$fOverrideSetPermissions
$ocID

Originally placed on which page.

$author
$folderTreeNodeID
$storageLocation

Methods

__construct()

No description

__call(mixed $nm, mixed $a)

For all methods that file does not implement, we pass through to the currently active file version object.

getPermissionObjectIdentifier()

Returns the identifier for the object, in this case the File ID.

string
getPassword()

Password used to protect the file if set.

int
getStorageLocationID()

Returns the FSL ID for the current file.

getFileVersions()

No description

reindex()

Reindex the attributes on this file.

setStorageLocation(StorageLocation $location)

Set the storage location for the file.

bool
setFileStorageLocation(StorageLocation $newLocation)

Move a file from its current FSL to a new FSL.

setPassword($pw)

Sets the access password on a file.

setOriginalPage($ocID)

No description

getOriginalPageObject()

No description

bool
resetPermissions($fOverrideSetPermissions = 0)

No description

int|null
getUserID()

Get the user ID of the author of the file (if available).

User|null
getUser()

Get the author of the file (if available).

setUser(User $user)

Set the user who authored the file.

int[]
getFileSetIDs()

Get the IDs of the file sets that this file belongs to.

FileSet[]
getFileSets()

Get the file sets that this file belongs to.

bool
isStarred(bool|User $u = false)

Tell if a file is starred by a user.

setDateAdded($fDateAdded)

Set the date a file was added Must call save() to persist.

getDateAdded()

No description

createNewVersion(bool $copyUnderlyingFile = false)

Create a new version of a file.

getVersionToModify(bool $forceCreateNew = false)

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.

int
getFileID()

File ID of the file.

string|null
getFileUUID()

Get the file UUID.

generateFileUUID()

Assign a new UUID to this file.

resetFileUUID()

Remove the the UUID from this file.

bool
hasFileUUID()

No description

setFileFolder(FileFolder $folder)

Folder to put the file in.

FileFolder|null
getFileFolderObject()

No description

getFileNodeObject()

No description

duplicate()

Duplicate a file The new file will have no version history.

Version|null
getApprovedVersion()

No description

bool
inFileSet(Set $fs)

If a file is in a particular file set.

bool
delete()

Removes a file, including all of its versions.

getRecentVersion()

Returns the most recent FileVersion object.

getVersion(int $fvID = null)

returns the FileVersion object for the provided fvID if none provided returns the approved version.

getVersionList()

Returns an array of all FileVersion objects owned by this file.

int
getTotalDownloads()

Total number of downloads for a file.

array
getDownloadStatistics(int $limit = 20) deprecated

No description

trackDownload(int $rcID = null)

Tracks File Download, takes the cID of the page that the file was downloaded from.

isError() deprecated

No description

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

No description

getAttributeValue(AttributeKeyInterface|string $ak)

Alias of getAttributeValueObject (assuming $createIfNotExists is false).

mixed
getAttribute(AttributeKeyInterface|string $ak, string|false $mode = false)

No description

clearAttribute(AttributeKeyInterface|string $ak)

No description

setAttribute(AttributeKeyInterface|string $ak, AbstractValue|EmptyRequestAttributeValue|array $value)

Sets the attribute of of the ObjectInterface instance to the specified value, and persists it.

getDetailsURL()

Returns a URL to the file in the file manager

save()

Persist any object changes to the database.

Details

__construct()

No description

__call(mixed $nm, mixed $a)

For all methods that file does not implement, we pass through to the currently active file version object.

Parameters

mixed $nm
mixed $a

getPermissionResponseClassName()

No description

getPermissionAssignmentClassName()

No description

getPermissionObjectKeyCategoryHandle()

No description

getPermissionObjectIdentifier()

Returns the identifier for the object, in this case the File ID.

string getPassword()

Password used to protect the file if set.

Return Value

string

int getStorageLocationID()

Returns the FSL ID for the current file.

Return Value

int

StorageLocation getFileStorageLocationObject()

No description

Return Value

StorageLocation

Version[] getFileVersions()

No description

Return Value

Version[]

reindex()

Reindex the attributes on this file.

setStorageLocation(StorageLocation $location)

Set the storage location for the file.

THIS DOES NOT MOVE THE FILE to move the file use setFileStorageLocation() Must call save() to persist changes.

Parameters

StorageLocation $location

bool setFileStorageLocation(StorageLocation $newLocation)

Move a file from its current FSL to a new FSL.

Parameters

StorageLocation $newLocation

Return Value

bool

false if the storage location is the same

Exceptions

Exception

setPassword($pw)

Sets the access password on a file.

Parameters

$pw string

setOriginalPage($ocID)

No description

Parameters

$ocID

getOriginalPageObject()

No description

bool overrideFileFolderPermissions()

No description

Return Value

bool

resetPermissions($fOverrideSetPermissions = 0)

No description

Parameters

$fOverrideSetPermissions

int|null getUserID()

Get the user ID of the author of the file (if available).

Return Value

int|null

User|null getUser()

Since: concrete5 8.5.2

Get the author of the file (if available).

Return Value

User|null

setUser(User $user)

Set the user who authored the file.

Parameters

User $user

int[] getFileSetIDs()

Get the IDs of the file sets that this file belongs to.

Return Value

int[]

FileSet[] getFileSets()

Get the file sets that this file belongs to.

Return Value

FileSet[]

bool isStarred(bool|User $u = false)

Tell if a file is starred by a user.

Parameters

bool|User $u

User to check against if they starred a file, If no user is provided we used the current user

Return Value

bool

true if the user starred

setDateAdded($fDateAdded)

Set the date a file was added Must call save() to persist.

Parameters

$fDateAdded

getDateAdded()

No description

Version createNewVersion(bool $copyUnderlyingFile = false)

Create a new version of a file.

Parameters

bool $copyUnderlyingFile

If we should copy the underlying file, or reference the original

Return Value

Version

Version getVersionToModify(bool $forceCreateNew = false)

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.

Parameters

bool $forceCreateNew

If we should always create a new version even if we are below the threshold

Return Value

Version

int getFileID()

File ID of the file.

Return Value

int

string|null getFileUUID()

Get the file UUID.

Return Value

string|null

File generateFileUUID()

Assign a new UUID to this file.

Return Value

File

File resetFileUUID()

Remove the the UUID from this file.

Return Value

File

bool hasFileUUID()

No description

Return Value

bool

setFileFolder(FileFolder $folder)

Folder to put the file in.

Parameters

FileFolder $folder

FileFolder|null getFileFolderObject()

No description

Return Value

FileFolder|null

NodeType getFileNodeObject()

No description

Return Value

NodeType

File duplicate()

Duplicate a file The new file will have no version history.

Return Value

File

Version|null getApprovedVersion()

No description

Return Value

Version|null

bool inFileSet(Set $fs)

If a file is in a particular file set.

Parameters

Set $fs

Return Value

bool

true if its in the set

bool delete()

Removes a file, including all of its versions.

*

Return Value

bool

returns false if the on_file_delete event says not to proceed, returns true on success

Exceptions

Exception

Version getRecentVersion()

Returns the most recent FileVersion object.

Return Value

Version

Version getVersion(int $fvID = null)

returns the FileVersion object for the provided fvID if none provided returns the approved version.

Parameters

int $fvID

Return Value

Version

Version[] getVersionList()

Returns an array of all FileVersion objects owned by this file.

Return Value

Version[]

int getTotalDownloads()

Total number of downloads for a file.

Return Value

int

array getDownloadStatistics(int $limit = 20) deprecated

deprecated Use the DownloadStatistics entity

No description

Parameters

int $limit

Return Value

array

trackDownload(int $rcID = null)

Tracks File Download, takes the cID of the page that the file was downloaded from.

Parameters

int $rcID

isError() deprecated

deprecated

No description

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

AttributeValueInterface|null getAttributeValue(AttributeKeyInterface|string $ak)

Alias of getAttributeValueObject (assuming $createIfNotExists is false).

Parameters

AttributeKeyInterface|string $ak

An attribute key instance (or its handle)

Return Value

AttributeValueInterface|null

See also

ObjectInterface::getAttributeValue

mixed getAttribute(AttributeKeyInterface|string $ak, string|false $mode = false)

No description

Parameters

AttributeKeyInterface|string $ak

An attribute key instance (or its handle)

string|false $mode

Return Value

mixed

See also

ObjectInterface::getAttribute

CategoryInterface getObjectAttributeCategory()

clearAttribute(AttributeKeyInterface|string $ak)

No description

Parameters

AttributeKeyInterface|string $ak

An attribute key instance (or its handle)

See also

ObjectInterface::clearAttribute

AttributeValueInterface setAttribute(AttributeKeyInterface|string $ak, AbstractValue|EmptyRequestAttributeValue|array $value)

Sets the attribute of of the ObjectInterface instance to the specified value, and persists it.

Parameters

AttributeKeyInterface|string $ak

An attribute key instance (or its handle)

AbstractValue|EmptyRequestAttributeValue|array $value

Return Value

AttributeValueInterface

See also

ObjectInterface::setAttribute

UrlInterface getDetailsURL()

Returns a URL to the file in the file manager

Return Value

UrlInterface

protected save()

Persist any object changes to the database.