FileReference implements FileInterface
Representation of a specific usage of a file with possibilities to override certain properties of the original file just for this usage of the file.
It acts as a decorator over the original file in the way that most method calls are directly passed along to the original file object.
All file related methods are directly passed along; only meta data functionality is adopted in this decorator class to priorities possible overrides for the metadata for this specific usage of the file.
Table of Contents
Interfaces
- FileInterface
- File Interface
Properties
- $mergedProperties : array<string|int, mixed>
- Properties merged with the parent object (File) if the value is not defined (NULL). Thus, FileReference properties act as overlays for the defined File properties.
- $originalFile : FileInterface
- Reference to the original File object underlying this FileReference.
- $propertiesOfFileReference : array<string|int, mixed>
- Various properties of the FileReference. Note that these information can be different to the ones found in the originalFile.
Methods
- __construct() : mixed
- Constructor for a file in use object. Should normally not be used directly, use the corresponding factory methods instead.
- __sleep() : array<string|int, string>
- Avoids exporting original file object which contains singleton dependencies that must not be serialized.
- __wakeup() : void
- delete() : bool
- Deletes only this particular FileReference from the persistence layer (table: sys_file_reference) and leaves the original file untouched.
- getAlternative() : string
- Returns the alternative text to this image
- getCombinedIdentifier() : string
- Returns a combined identifier of the underlying original file
- getContents() : string
- Get the contents of this file
- getCreationTime() : int
- Returns the creation time of the file as Unix timestamp
- getDescription() : string
- Returns the description text to this file
- getExtension() : string
- Get the file extension of this file
- getForLocalProcessing() : non-empty-string
- Returns a path to a local version of this file to process it locally (e.g. with some system tool).
- getHashedIdentifier() : non-empty-string
- getIdentifier() : non-empty-string
- Returns the identifier of the underlying original file
- getLink() : string
- Returns the link that should be active when clicking on this image
- getMimeType() : non-empty-string
- Get the MIME type of this file
- getModificationTime() : int
- Returns the modification time of the file as Unix timestamp
- getName() : string
- getNameWithoutExtension() : string
- Returns the basename (the name without extension) of this file.
- getOriginalFile() : File
- Gets the original file being referenced.
- getParentFolder() : FolderInterface
- getProperties() : array<string|int, mixed>
- Gets all properties, falling back to values of the parent.
- getProperty() : mixed
- Gets a property, falling back to values of the parent.
- getPublicUrl() : non-empty-string|null
- Returns a publicly accessible URL for this file
- getReferenceProperties() : array<string|int, mixed>
- Gets all properties of the file reference.
- getReferenceProperty() : mixed
- Gets a property of the file reference.
- getSha1() : non-empty-string
- Returns the Sha1 of this file
- getSize() : int<0, max>
- MUST return the size of the file as unsigned int i.e. 0-max.
- getStorage() : ResourceStorage
- Get the storage the original file is located in
- getTitle() : string
- Returns the title text to this image
- getType() : int
- Returns the fileType of this file
- getUid() : int
- Returns the uid of this File In Use
- hasProperty() : bool
- Returns true if the given key exists for this file.
- isIndexed() : bool
- Returns TRUE if this file is indexed.
- isMissing() : bool
- Check if file is marked as missing by indexer
- isType() : bool
- rename() : FileInterface
- Renames the fileName in this particular usage.
- setContents() : $this
- Replace the current file contents with the given string
- toArray() : array<non-empty-string, mixed>
- Returns an array representation of the file.
- restoreNonNullValuesCallback() : mixed
- Callback to handle the NULL value feature
Properties
$mergedProperties
Properties merged with the parent object (File) if the value is not defined (NULL). Thus, FileReference properties act as overlays for the defined File properties.
protected
array<string|int, mixed>
$mergedProperties
= []
$originalFile
Reference to the original File object underlying this FileReference.
protected
FileInterface
$originalFile
$propertiesOfFileReference
Various properties of the FileReference. Note that these information can be different to the ones found in the originalFile.
protected
array<string|int, mixed>
$propertiesOfFileReference
Methods
__construct()
Constructor for a file in use object. Should normally not be used directly, use the corresponding factory methods instead.
public
__construct(array<string|int, mixed> $fileReferenceData[, ResourceFactory $factory = null ]) : mixed
Parameters
- $fileReferenceData : array<string|int, mixed>
- $factory : ResourceFactory = null
Tags
__sleep()
Avoids exporting original file object which contains singleton dependencies that must not be serialized.
public
__sleep() : array<string|int, string>
Return values
array<string|int, string>__wakeup()
public
__wakeup() : void
delete()
Deletes only this particular FileReference from the persistence layer (table: sys_file_reference) and leaves the original file untouched.
public
delete() : bool
Return values
boolgetAlternative()
Returns the alternative text to this image
public
getAlternative() : string
Tags
Return values
stringgetCombinedIdentifier()
Returns a combined identifier of the underlying original file
public
getCombinedIdentifier() : string
Return values
string —Combined storage and file identifier, e.g. StorageUID:path/and/fileName.png
getContents()
Get the contents of this file
public
getContents() : string
Return values
stringgetCreationTime()
Returns the creation time of the file as Unix timestamp
public
getCreationTime() : int
Return values
intgetDescription()
Returns the description text to this file
public
getDescription() : string
Tags
Return values
stringgetExtension()
Get the file extension of this file
public
getExtension() : string
Return values
string —The file extension
getForLocalProcessing()
Returns a path to a local version of this file to process it locally (e.g. with some system tool).
public
getForLocalProcessing([bool $writable = true ]) : non-empty-string
If the file is normally located on a remote storages, this creates a local copy. If the file is already on the local system, this only makes a new copy if $writable is set to TRUE.
Parameters
- $writable : bool = true
-
Set this to FALSE if you only want to do read operations on the file.
Return values
non-empty-stringgetHashedIdentifier()
public
getHashedIdentifier() : non-empty-string
Return values
non-empty-stringgetIdentifier()
Returns the identifier of the underlying original file
public
getIdentifier() : non-empty-string
Return values
non-empty-stringgetLink()
Returns the link that should be active when clicking on this image
public
getLink() : string
Tags
Return values
stringgetMimeType()
Get the MIME type of this file
public
getMimeType() : non-empty-string
Return values
non-empty-string —mime type
getModificationTime()
Returns the modification time of the file as Unix timestamp
public
getModificationTime() : int
Return values
intgetName()
public
getName() : string
Return values
stringgetNameWithoutExtension()
Returns the basename (the name without extension) of this file.
public
getNameWithoutExtension() : string
Return values
stringgetOriginalFile()
Gets the original file being referenced.
public
getOriginalFile() : File
Return values
FilegetParentFolder()
public
getParentFolder() : FolderInterface
Return values
FolderInterfacegetProperties()
Gets all properties, falling back to values of the parent.
public
getProperties() : array<string|int, mixed>
Return values
array<string|int, mixed>getProperty()
Gets a property, falling back to values of the parent.
public
getProperty(non-empty-string $key) : mixed
Parameters
- $key : non-empty-string
-
The property to be looked up
Tags
getPublicUrl()
Returns a publicly accessible URL for this file
public
getPublicUrl() : non-empty-string|null
WARNING: Access to the file may be restricted by further means, e.g. some web-based authentication. You have to take care of this yourself.
Return values
non-empty-string|null —NULL if file is missing or deleted, the generated url otherwise
getReferenceProperties()
Gets all properties of the file reference.
public
getReferenceProperties() : array<string|int, mixed>
Return values
array<string|int, mixed>getReferenceProperty()
Gets a property of the file reference.
public
getReferenceProperty(string $key) : mixed
Parameters
- $key : string
-
The property to be looked up
Tags
getSha1()
Returns the Sha1 of this file
public
getSha1() : non-empty-string
Return values
non-empty-stringgetSize()
MUST return the size of the file as unsigned int i.e. 0-max.
public
getSize() : int<0, max>
Return values
int<0, max>getStorage()
Get the storage the original file is located in
public
getStorage() : ResourceStorage
Return values
ResourceStoragegetTitle()
Returns the title text to this image
public
getTitle() : string
Tags
Return values
stringgetType()
Returns the fileType of this file
public
getType() : int
Return values
int —$fileType
getUid()
Returns the uid of this File In Use
public
getUid() : int
Return values
inthasProperty()
Returns true if the given key exists for this file.
public
hasProperty(non-empty-string $key) : bool
Parameters
- $key : non-empty-string
-
The property to be looked up
Return values
boolisIndexed()
Returns TRUE if this file is indexed.
public
isIndexed() : bool
This is always true for FileReference objects, as they rely on a sys_file_reference record to be present, which in turn can only exist if the original file is indexed.
Return values
boolisMissing()
Check if file is marked as missing by indexer
public
isMissing() : bool
Return values
boolisType()
public
isType(FileType $fileType) : bool
Parameters
- $fileType : FileType
Return values
boolrename()
Renames the fileName in this particular usage.
public
rename(non-empty-string $newName[, string|DuplicationBehavior $conflictMode = DuplicationBehavior::RENAME ]) : FileInterface
Parameters
- $newName : non-empty-string
-
The new file name
- $conflictMode : string|DuplicationBehavior = DuplicationBehavior::RENAME
Tags
Return values
FileInterfacesetContents()
Replace the current file contents with the given string
public
setContents(string $contents) : $this
Parameters
- $contents : string
-
The contents to write to the file.
Return values
$thistoArray()
Returns an array representation of the file.
public
toArray() : array<non-empty-string, mixed>
(This is used by the generic listing module vidi when displaying file records.)
Return values
array<non-empty-string, mixed> —Array of main data of the file. Don't rely on all data to be present here, it's just a selection of the most relevant information.
restoreNonNullValuesCallback()
Callback to handle the NULL value feature
protected
restoreNonNullValuesCallback(mixed &$value, mixed $key) : mixed
Parameters
- $value : mixed
- $key : mixed