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 (database table sys_file_reference) but 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() : string
- Returns a path to a local version of this file to process it locally (e.g. with some system tool).
- getHashedIdentifier() : string
- Get hashed identifier
- getIdentifier() : string
- Returns the identifier of the underlying original file
- getLink() : string
- Returns the link that should be active when clicking on this image
- getMimeType() : string
- Get the MIME type of this file
- getModificationTime() : int
- Returns the modification time of the file as Unix timestamp
- getName() : string
- Returns the name of this file
- getNameWithoutExtension() : string
- Returns the basename (the name without extension) of this file.
- getOriginalFile() : File
- Gets the original file being referenced.
- getParentFolder() : FolderInterface
- Returns the parent folder.
- 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() : 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() : string
- Returns the Sha1 of this file
- getSize() : int
- Returns the size of this file
- 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
- rename() : File
- Renames the fileName in this particular usage.
- setContents() : File
- Replace the current file contents with the given string
- toArray() : array<string|int, 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 (database table sys_file_reference) but leaves the original file untouched.
public
delete() : bool
Tags
Return values
bool —TRUE if deletion succeeded
getAlternative()
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
string —File contents
getCreationTime()
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 ]) : 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
stringgetHashedIdentifier()
Get hashed identifier
public
getHashedIdentifier() : string
Return values
stringgetIdentifier()
Returns the identifier of the underlying original file
public
getIdentifier() : string
Return values
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() : string
Return values
string —mime type
getModificationTime()
Returns the modification time of the file as Unix timestamp
public
getModificationTime() : int
Return values
intgetName()
Returns the name of this file
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()
Returns the parent folder.
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(string $key) : mixed
Parameters
- $key : string
-
The property to be looked up
Tags
getPublicUrl()
Returns a publicly accessible URL for this file
public
getPublicUrl([bool $relativeToCurrentScript = false ]) : 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.
Parameters
- $relativeToCurrentScript : bool = false
-
Determines whether the URL returned should be relative to the current script, in case it is relative at all (only for the LocalDriver). Deprecated since TYPO3 v11, will be removed in TYPO3 v12.0
Return values
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() : string
Return values
stringgetSize()
Returns the size of this file
public
getSize() : int
Return values
intgetStorage()
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(string $key) : bool
Parameters
- $key : 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
boolrename()
Renames the fileName in this particular usage.
public
rename(string $newName[, string $conflictMode = DuplicationBehavior::RENAME ]) : File
Parameters
- $newName : string
-
The new name
- $conflictMode : string = DuplicationBehavior::RENAME
Return values
FilesetContents()
Replace the current file contents with the given string
public
setContents(string $contents) : File
Parameters
- $contents : string
-
The contents to write to the file.
Return values
File —The file object (allows chaining).
toArray()
Returns an array representation of the file.
public
toArray() : array<string|int, mixed>
(This is used by the generic listing module vidi when displaying file records.)
Return values
array<string|int, 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