‪TYPO3CMS  10.4
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)
 
bool hasProperty ($key)
 
mixed getProperty ($key)
 
mixed getReferenceProperty ($key)
 
array getProperties ()
 
array getReferenceProperties ()
 
string getName ()
 
string getTitle ()
 
string getAlternative ()
 
string getDescription ()
 
string getLink ()
 
int getUid ()
 
int getSize ()
 
string getSha1 ()
 
string getExtension ()
 
string getNameWithoutExtension ()
 
string getMimeType ()
 
int getModificationTime ()
 
int getCreationTime ()
 
int getType ()
 
bool isMissing ()
 
string getContents ()
 
File setContents ($contents)
 
ResourceStorage getStorage ()
 
string getIdentifier ()
 
string getCombinedIdentifier ()
 
 delete ()
 
 rename ($newName, $conflictMode=DuplicationBehavior::RENAME)
 
string null getPublicUrl ($relativeToCurrentScript=false)
 
bool isIndexed ()
 
string getForLocalProcessing ($writable=true)
 
array toArray ()
 
File getOriginalFile ()
 
string getHashedIdentifier ()
 
FolderInterface getParentFolder ()
 
string[] __sleep ()
 
 __wakeup ()
 

Protected Member Functions

 restoreNonNullValuesCallback (&$value, $key)
 

Protected Attributes

array $propertiesOfFileReference
 
string $name
 
File $originalFile
 
array $mergedProperties = array( )
 

Private Member Functions

FileInterface 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 32 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.

Parameters
array$fileReferenceData
ResourceFactory$factory
Exceptions

Definition at line 72 of file FileReference.php.

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

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.

Returns
‪string[]

Definition at line 521 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 (database table sys_file_reference) but leaves the original file untouched.

Exceptions

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 408 of file FileReference.php.

◆ getAlternative()

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

Returns the alternative text to this image

Todo:
‪Possibly move this to the image domain object instead
Returns
‪string

Definition at line 216 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

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

Definition at line 397 of file FileReference.php.

◆ getContents()

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

Get the contents of this file

Returns
‪string File contents

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 353 of file FileReference.php.

◆ getCreationTime()

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

Returns the creation time of the file as Unix timestamp

Returns
‪int

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 320 of file FileReference.php.

◆ getDescription()

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

Returns the description text to this file

Todo:
‪Possibly move this to the image domain object instead
Returns
‪string

Definition at line 228 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

Returns
‪string The file extension

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 280 of file FileReference.php.

◆ getFileObject()

FileInterface TYPO3\CMS\Core\Resource\FileReference::getFileObject ( int  $uidLocal,
ResourceFactory  $factory = null 
)
private
Parameters
int$uidLocal
ResourceFactory | null$factory
Returns
FileInterface
Exceptions
Exception

Definition at line 89 of file FileReference.php.

Referenced by TYPO3\CMS\Core\Resource\FileReference\__construct(), and TYPO3\CMS\Core\Resource\FileReference\__wakeup().

◆ getForLocalProcessing()

string TYPO3\CMS\Core\Resource\FileReference::getForLocalProcessing (   $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.

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

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 468 of file FileReference.php.

◆ getHashedIdentifier()

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

◆ getIdentifier()

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

Returns the identifier of the underlying original file

Returns
‪string

Implements TYPO3\CMS\Core\Resource\ResourceInterface.

Definition at line 387 of file FileReference.php.

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

Todo:
‪Move this to the image domain object instead
Returns
‪string

Definition at line 240 of file FileReference.php.

◆ getMimeType()

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

Get the MIME type of this file

Returns
‪string mime type

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 300 of file FileReference.php.

◆ getModificationTime()

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

Returns the modification time of the file as Unix timestamp

Returns
‪int

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 310 of file FileReference.php.

◆ getName()

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

Returns the name of this file

Returns
‪string

Implements TYPO3\CMS\Core\Resource\ResourceInterface.

Definition at line 192 of file FileReference.php.

◆ getNameWithoutExtension()

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

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

Returns
‪string

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 290 of file FileReference.php.

◆ getOriginalFile()

File TYPO3\CMS\Core\Resource\FileReference::getOriginalFile ( )

Gets the original file being referenced.

Returns
File

Definition at line 490 of file FileReference.php.

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

◆ getParentFolder()

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

Returns the parent folder.

Returns
FolderInterface

Implements TYPO3\CMS\Core\Resource\ResourceInterface.

Definition at line 510 of file FileReference.php.

References TYPO3\CMS\Core\Resource\ResourceInterface\getParentFolder().

◆ getProperties()

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

◆ getProperty()

◆ getPublicUrl()

string null TYPO3\CMS\Core\Resource\FileReference::getPublicUrl (   $relativeToCurrentScript = false)

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.

Parameters
bool$relativeToCurrentScript‪Determines whether the URL returned should be relative to the current script, in case it is relative at all (only for the LocalDriver)
Returns
‪string|null NULL if file is missing or deleted, the generated url otherwise

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 442 of file FileReference.php.

◆ getReferenceProperties()

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

Gets all properties of the file reference.

Returns
‪array

Definition at line 182 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.

Parameters
string$key‪The property to be looked up
Returns
‪mixed
Exceptions

Definition at line 134 of file FileReference.php.

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

◆ getSha1()

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

Returns the Sha1 of this file

Returns
‪string

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 270 of file FileReference.php.

◆ getSize()

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

Returns the size of this file

Returns
‪int

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 260 of file FileReference.php.

◆ getStorage()

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

Get the storage the original file is located in

Returns
ResourceStorage

Implements TYPO3\CMS\Core\Resource\ResourceInterface.

Definition at line 377 of file FileReference.php.

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

◆ getTitle()

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

Returns the title text to this image

Todo:
‪Possibly move this to the image domain object instead
Returns
‪string

Definition at line 204 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

Returns
‪int $fileType

Definition at line 330 of file FileReference.php.

◆ getUid()

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

Returns the uid of this File In Use

Returns
‪int

Definition at line 250 of file FileReference.php.

◆ hasProperty()

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

Returns true if the given key exists for this file.

Parameters
string$key‪The property to be looked up
Returns
‪bool

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 106 of file FileReference.php.

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

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

◆ isIndexed()

bool 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.

Returns
‪bool

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 455 of file FileReference.php.

◆ isMissing()

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

Check if file is marked as missing by indexer

Returns
‪bool

Definition at line 340 of file FileReference.php.

◆ rename()

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

Renames the fileName in this particular usage.

Parameters
string$newName‪The new name
string$conflictMode

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 422 of file FileReference.php.

◆ restoreNonNullValuesCallback()

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

Callback to handle the NULL value feature

Parameters
mixed$value
mixed$key

Definition at line 170 of file FileReference.php.

◆ setContents()

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

Replace the current file contents with the given string

Parameters
string$contents‪The contents to write to the file.
Returns
File The file object (allows chaining).

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 364 of file FileReference.php.

References TYPO3\CMS\Core\Resource\File\setContents().

◆ toArray()

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

Returns an array representation of the file. (This is used by the generic listing module vidi when displaying file records.)

Returns
‪array 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.

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 479 of file FileReference.php.

Member Data Documentation

◆ $mergedProperties

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

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 60 of file FileReference.php.

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

◆ $name

string TYPO3\CMS\Core\Resource\FileReference::$name
protected

The file name of this file. It's either the fileName of the original underlying file, or the overlay file name supplied by the user for this particular usage (FileReference) of the file.

Definition at line 46 of file FileReference.php.

◆ $originalFile

File TYPO3\CMS\Core\Resource\FileReference::$originalFile
protected

Reference to the original File object underlying this FileReference.

Definition at line 52 of file FileReference.php.

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

◆ $propertiesOfFileReference

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

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

Definition at line 39 of file FileReference.php.

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