‪TYPO3CMS  ‪main
TYPO3\CMS\Core\Resource\FileReference Class Reference
Inheritance diagram for TYPO3\CMS\Core\Resource\FileReference:
TYPO3\CMS\Core\Resource\FileInterface TYPO3\CMS\Core\Resource\ResourceInterface

Public Member Functions

 __construct (array $fileReferenceData, $factory=null)
 hasProperty (string $key)
 getProperty (string $key)
mixed getReferenceProperty ($key)
array getProperties ()
array getReferenceProperties ()
 getName ()
string getTitle ()
string getAlternative ()
string getDescription ()
string getLink ()
int getUid ()
int< 0, getSize():int { return $this-> originalFile getSize ()
non empty string getSha1 ()
string getExtension ()
 getNameWithoutExtension ()
non empty string getMimeType ()
 getModificationTime ()
 getCreationTime ()
int getType ()
bool isMissing ()
 getContents ()
$this setContents (string $contents)
 getStorage ()
non empty string getIdentifier ()
string getCombinedIdentifier ()
 delete ()
 rename (string $newName, $conflictMode=DuplicationBehavior::RENAME)
non empty string null getPublicUrl ()
 isIndexed ()
non empty string getForLocalProcessing (bool $writable=true)
non empty string getHashedIdentifier ()
 getParentFolder ()
string[] __sleep ()
 __wakeup ()

Public Attributes

array< non-empty-string, function toArray():array { $array=array_merge( $this->originalFile->toArray(), $this->propertiesOfFileReference);return $array;} public File function getOriginalFile() { return $this-> originalFile

Protected Member Functions

 restoreNonNullValuesCallback (&$value, $key)

Protected Attributes

array $propertiesOfFileReference
FileInterface $originalFile
array $mergedProperties = array( )

Private Member Functions

 getFileObject (int $uidLocal, ResourceFactory $factory=null)

Detailed Description

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.

Definition at line 36 of file FileReference.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Resource\FileReference::__construct ( array  $fileReferenceData,
  $factory = null 

Constructor for a file in use object. Should normally not be used directly, use the corresponding factory methods instead.


Definition at line 68 of file FileReference.php.

References TYPO3\CMS\Core\Resource\FileReference\getFileObject(), and TYPO3\CMS\Core\Resource\FileReference\originalFile.

Member Function Documentation

◆ __sleep()

string [] TYPO3\CMS\Core\Resource\FileReference::__sleep ( )

Avoids exporting original file object which contains singleton dependencies that must not be serialized.


Definition at line 489 of file FileReference.php.

◆ __wakeup()

TYPO3\CMS\Core\Resource\FileReference::__wakeup ( )

◆ delete()

TYPO3\CMS\Core\Resource\FileReference::delete ( )

Deletes only this particular FileReference from the persistence layer (table: sys_file_reference) and leaves the original file untouched.

Definition at line 380 of file FileReference.php.

References TYPO3\CMS\Core\Resource\FileReference\getUid().

◆ getAlternative()

string TYPO3\CMS\Core\Resource\FileReference::getAlternative ( )

Returns the alternative text to this image

‪Possibly move this to the image domain object instead

Definition at line 201 of file FileReference.php.

References TYPO3\CMS\Core\Resource\FileReference\getProperty().

◆ getCombinedIdentifier()

string TYPO3\CMS\Core\Resource\FileReference::getCombinedIdentifier ( )

Returns a combined identifier of the underlying original file

‪string Combined storage and file identifier, e.g. StorageUID:path/and/fileName.png

Definition at line 371 of file FileReference.php.

References TYPO3\CMS\Core\Resource\File\getCombinedIdentifier(), and TYPO3\CMS\Core\Resource\FileReference\originalFile.

◆ getContents()

TYPO3\CMS\Core\Resource\FileReference::getContents ( )

Get the contents of this file

Definition at line 328 of file FileReference.php.

References TYPO3\CMS\Core\Resource\File\getContents(), and TYPO3\CMS\Core\Resource\FileReference\originalFile.

◆ getCreationTime()

TYPO3\CMS\Core\Resource\FileReference::getCreationTime ( )

Returns the creation time of the file as Unix timestamp

Definition at line 297 of file FileReference.php.

References TYPO3\CMS\Core\Resource\AbstractFile\getCreationTime(), and TYPO3\CMS\Core\Resource\FileReference\originalFile.

◆ getDescription()

string TYPO3\CMS\Core\Resource\FileReference::getDescription ( )

Returns the description text to this file

‪Possibly move this to the image domain object instead

Definition at line 213 of file FileReference.php.

References TYPO3\CMS\Core\Resource\FileReference\getProperty().

◆ getExtension()

string TYPO3\CMS\Core\Resource\FileReference::getExtension ( )

Get the file extension of this file

‪string The file extension

Definition at line 263 of file FileReference.php.

References TYPO3\CMS\Core\Resource\AbstractFile\getExtension(), and TYPO3\CMS\Core\Resource\FileReference\originalFile.

◆ getFileObject()

TYPO3\CMS\Core\Resource\FileReference::getFileObject ( int  $uidLocal,
ResourceFactory  $factory = null 

◆ getForLocalProcessing()

non empty string TYPO3\CMS\Core\Resource\FileReference::getForLocalProcessing ( bool  $writable = true)

Returns a path to a local version of this file to process it locally (e.g. with some system tool). 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.

bool$writable‪Set this to FALSE if you only want to do read operations on the file.

Definition at line 443 of file FileReference.php.

References TYPO3\CMS\Core\Resource\AbstractFile\getForLocalProcessing(), and TYPO3\CMS\Core\Resource\FileReference\originalFile.

◆ getHashedIdentifier()

non empty string TYPO3\CMS\Core\Resource\FileReference::getHashedIdentifier ( )

◆ getIdentifier()

non empty string TYPO3\CMS\Core\Resource\FileReference::getIdentifier ( )

Returns the identifier of the underlying original file


Implements TYPO3\CMS\Core\Resource\ResourceInterface.

Definition at line 361 of file FileReference.php.

References TYPO3\CMS\Core\Resource\AbstractFile\getIdentifier(), and TYPO3\CMS\Core\Resource\FileReference\originalFile.

Referenced by TYPO3\CMS\Core\Resource\FileReference\getHashedIdentifier().

◆ getLink()

string TYPO3\CMS\Core\Resource\FileReference::getLink ( )

Returns the link that should be active when clicking on this image

‪Move this to the image domain object instead

Definition at line 225 of file FileReference.php.

◆ getMimeType()

non empty string TYPO3\CMS\Core\Resource\FileReference::getMimeType ( )

Get the MIME type of this file

‪non-empty-string mime type

Definition at line 281 of file FileReference.php.

References TYPO3\CMS\Core\Resource\AbstractFile\getMimeType(), and TYPO3\CMS\Core\Resource\FileReference\originalFile.

◆ getModificationTime()

TYPO3\CMS\Core\Resource\FileReference::getModificationTime ( )

Returns the modification time of the file as Unix timestamp

Definition at line 289 of file FileReference.php.

References TYPO3\CMS\Core\Resource\AbstractFile\getModificationTime(), and TYPO3\CMS\Core\Resource\FileReference\originalFile.

◆ getName()

TYPO3\CMS\Core\Resource\FileReference::getName ( )

◆ getNameWithoutExtension()

TYPO3\CMS\Core\Resource\FileReference::getNameWithoutExtension ( )

Returns the basename (the name without extension) of this file.

Definition at line 271 of file FileReference.php.

References TYPO3\CMS\Core\Resource\AbstractFile\getNameWithoutExtension(), and TYPO3\CMS\Core\Resource\FileReference\originalFile.

◆ getParentFolder()

TYPO3\CMS\Core\Resource\FileReference::getParentFolder ( )

◆ getProperties()

◆ getProperty()

◆ getPublicUrl()

non empty string null TYPO3\CMS\Core\Resource\FileReference::getPublicUrl ( )

Returns a publicly accessible URL for this file

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.

‪non-empty-string|null NULL if file is missing or deleted, the generated url otherwise

Definition at line 419 of file FileReference.php.

References TYPO3\CMS\Core\Resource\File\getPublicUrl(), and TYPO3\CMS\Core\Resource\FileReference\originalFile.

◆ getReferenceProperties()

array TYPO3\CMS\Core\Resource\FileReference::getReferenceProperties ( )

Gets all properties of the file reference.


Definition at line 172 of file FileReference.php.

References TYPO3\CMS\Core\Resource\FileReference\$propertiesOfFileReference.

◆ getReferenceProperty()

mixed TYPO3\CMS\Core\Resource\FileReference::getReferenceProperty (   $key)

Gets a property of the file reference.

string$key‪The property to be looked up

Definition at line 124 of file FileReference.php.

Referenced by TYPO3\CMS\Core\Resource\FileRepository\reapplySorting().

◆ getSha1()

non empty string TYPO3\CMS\Core\Resource\FileReference::getSha1 ( )

Returns the Sha1 of this file


Definition at line 253 of file FileReference.php.

References TYPO3\CMS\Core\Resource\File\getSha1(), and TYPO3\CMS\Core\Resource\FileReference\originalFile.

◆ getSize()

int<0, getSize(): int { return $this-> originalFile TYPO3\CMS\Core\Resource\FileReference::getSize ( )
‪int<0, max>

◆ getStorage()

TYPO3\CMS\Core\Resource\FileReference::getStorage ( )

◆ getTitle()

string TYPO3\CMS\Core\Resource\FileReference::getTitle ( )

Returns the title text to this image

‪Possibly move this to the image domain object instead

Definition at line 189 of file FileReference.php.

References TYPO3\CMS\Core\Resource\FileReference\getProperty().

◆ getType()

int TYPO3\CMS\Core\Resource\FileReference::getType ( )

Returns the fileType of this file

‪int $fileType

Definition at line 307 of file FileReference.php.

References TYPO3\CMS\Core\Resource\AbstractFile\getType(), and TYPO3\CMS\Core\Resource\FileReference\originalFile.

◆ getUid()

int TYPO3\CMS\Core\Resource\FileReference::getUid ( )

Returns the uid of this File In Use


Definition at line 235 of file FileReference.php.

Referenced by TYPO3\CMS\Core\Resource\FileReference\delete().

◆ hasProperty()

TYPO3\CMS\Core\Resource\FileReference::hasProperty ( string  $key)

Returns true if the given key exists for this file.

non-empty-string$key‪The property to be looked up

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 97 of file FileReference.php.

References TYPO3\CMS\Core\Resource\FileReference\getProperties().

Referenced by TYPO3\CMS\Core\Resource\FileReference\getProperty().

◆ isIndexed()

TYPO3\CMS\Core\Resource\FileReference::isIndexed ( )

Returns TRUE if this file is indexed. 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.

Definition at line 430 of file FileReference.php.

◆ isMissing()

bool TYPO3\CMS\Core\Resource\FileReference::isMissing ( )

Check if file is marked as missing by indexer


Definition at line 317 of file FileReference.php.

References TYPO3\CMS\Core\Resource\File\getProperty(), and TYPO3\CMS\Core\Resource\FileReference\originalFile.

◆ rename()

TYPO3\CMS\Core\Resource\FileReference::rename ( string  $newName,
  $conflictMode = DuplicationBehavior::RENAME 

Renames the fileName in this particular usage.

non-empty-string$newName‪The new file name
string | DuplicationBehavior$conflictMode
‪change $conflictMode parameter type to DuplicationBehavior in TYPO3 v14.0

Definition at line 400 of file FileReference.php.

◆ restoreNonNullValuesCallback()

TYPO3\CMS\Core\Resource\FileReference::restoreNonNullValuesCallback ( $value,

Callback to handle the NULL value feature


Definition at line 160 of file FileReference.php.

Referenced by TYPO3\CMS\Core\Resource\FileReference\getProperties().

◆ setContents()

$this TYPO3\CMS\Core\Resource\FileReference::setContents ( string  $contents)

Replace the current file contents with the given string

string$contents‪The contents to write to the file.

Definition at line 339 of file FileReference.php.

References TYPO3\CMS\Core\Resource\FileReference\originalFile, and TYPO3\CMS\Core\Resource\File\setContents().

Member Data Documentation

◆ $mergedProperties

array TYPO3\CMS\Core\Resource\FileReference::$mergedProperties = array( )

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.

Definition at line 57 of file FileReference.php.

Referenced by TYPO3\CMS\Core\Resource\FileReference\getProperties().

◆ $originalFile

FileInterface TYPO3\CMS\Core\Resource\FileReference::$originalFile

Reference to the original File object underlying this FileReference.

Definition at line 49 of file FileReference.php.

◆ $propertiesOfFileReference

array TYPO3\CMS\Core\Resource\FileReference::$propertiesOfFileReference

Various properties of the FileReference. Note that these information can be different to the ones found in the originalFile.

Definition at line 43 of file FileReference.php.

Referenced by TYPO3\CMS\Core\Resource\FileReference\getProperties(), and TYPO3\CMS\Core\Resource\FileReference\getReferenceProperties().

◆ originalFile

array<non-empty-string, function toArray(): array { $array = array_merge($this->originalFile->toArray(), $this->propertiesOfFileReference); return $array; } public File function getOriginalFile() { return $this-> TYPO3\CMS\Core\Resource\FileReference::originalFile