TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
FileReference Class Reference
Inheritance diagram for FileReference:
FileInterface ResourceInterface

Public Member Functions

 hasProperty ($key)
 
 getProperty ($key)
 
 getReferenceProperty ($key)
 
 getProperties ()
 
 getReferenceProperties ()
 
 getName ()
 
 getTitle ()
 
 getAlternative ()
 
 getDescription ()
 
 getLink ()
 
 getUid ()
 
 getSize ()
 
 getSha1 ()
 
 getExtension ()
 
 getNameWithoutExtension ()
 
 getMimeType ()
 
 getModificationTime ()
 
 getCreationTime ()
 
 getType ()
 
 isMissing ()
 
 getContents ()
 
 setContents ($contents)
 
 getStorage ()
 
 getIdentifier ()
 
 getCombinedIdentifier ()
 
 delete ()
 
 rename ($newName)
 
 getPublicUrl ($relativeToCurrentScript=false)
 
 isIndexed ()
 
 getForLocalProcessing ($writable=true)
 
 toArray ()
 
 getOriginalFile ()
 
 getHashedIdentifier ()
 
 getParentFolder ()
 

Protected Member Functions

 restoreNonNullValuesCallback (&$value, $key)
 

Protected Attributes

 $propertiesOfFileReference
 
 $uidOfFileReference
 
 $name
 
 $originalFile
 
 $mergedProperties = []
 

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 29 of file core/Classes/Resource/FileReference.php.

Member Function Documentation

delete ( )

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

Exceptions
BadMethodCallException
Returns
bool TRUE if deletion succeeded

Implements FileInterface.

Definition at line 414 of file core/Classes/Resource/FileReference.php.

getAlternative ( )

Returns the alternative text to this image

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

Definition at line 221 of file core/Classes/Resource/FileReference.php.

References FileReference\getProperty().

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 402 of file core/Classes/Resource/FileReference.php.

getContents ( )

Get the contents of this file

Returns
string File contents

Implements FileInterface.

Definition at line 358 of file core/Classes/Resource/FileReference.php.

getCreationTime ( )

Returns the creation time of the file as Unix timestamp

Returns
int

Implements FileInterface.

Definition at line 325 of file core/Classes/Resource/FileReference.php.

getDescription ( )

Returns the description text to this file

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

Definition at line 233 of file core/Classes/Resource/FileReference.php.

References FileReference\getProperty().

getExtension ( )

Get the file extension of this file

Returns
string The file extension

Implements FileInterface.

Definition at line 285 of file core/Classes/Resource/FileReference.php.

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$writableSet this to FALSE if you only want to do read operations on the file.
Returns
string

Implements FileInterface.

Definition at line 475 of file core/Classes/Resource/FileReference.php.

getHashedIdentifier ( )

Get hashed identifier

Returns
string

Implements ResourceInterface.

Definition at line 507 of file core/Classes/Resource/FileReference.php.

References FileReference\getIdentifier(), and FileReference\getStorage().

getIdentifier ( )

Returns the identifier of the underlying original file

Returns
string

Implements ResourceInterface.

Definition at line 392 of file core/Classes/Resource/FileReference.php.

Referenced by FileReference\getHashedIdentifier().

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 245 of file core/Classes/Resource/FileReference.php.

getMimeType ( )

Get the MIME type of this file

Returns
string mime type

Implements FileInterface.

Definition at line 305 of file core/Classes/Resource/FileReference.php.

getModificationTime ( )

Returns the modification time of the file as Unix timestamp

Returns
int

Implements FileInterface.

Definition at line 315 of file core/Classes/Resource/FileReference.php.

getName ( )

Returns the name of this file

Returns
string

Implements ResourceInterface.

Definition at line 197 of file core/Classes/Resource/FileReference.php.

getNameWithoutExtension ( )

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

Returns
string

Implements FileInterface.

Definition at line 295 of file core/Classes/Resource/FileReference.php.

getOriginalFile ( )

Gets the original file being referenced.

Returns
File

Definition at line 497 of file core/Classes/Resource/FileReference.php.

References FileReference\$originalFile.

getParentFolder ( )

Returns the parent folder.

Returns
FolderInterface

Implements ResourceInterface.

Definition at line 517 of file core/Classes/Resource/FileReference.php.

getProperties ( )

Gets all properties, falling back to values of the parent.

Returns
array

Definition at line 152 of file core/Classes/Resource/FileReference.php.

References FileReference\$mergedProperties, FileReference\$propertiesOfFileReference, and ArrayUtility\mergeRecursiveWithOverrule().

Referenced by FileReference\getProperty(), and FileReference\hasProperty().

getProperty (   $key)

Gets a property, falling back to values of the parent.

Parameters
string$keyThe property to be looked up
Returns
mixed
Exceptions
InvalidArgumentException

Implements FileInterface.

Definition at line 123 of file core/Classes/Resource/FileReference.php.

References FileReference\getProperties(), and FileReference\hasProperty().

Referenced by FileReference\getAlternative(), FileReference\getDescription(), FileReference\getTitle(), ImageViewHelper\render(), and ImageViewHelper\renderStatic().

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$relativeToCurrentScriptDetermines whether the URL returned should be relative to the current script, in case it is relative at all (only for the LocalDriver)
Returns
string

Implements FileInterface.

Definition at line 449 of file core/Classes/Resource/FileReference.php.

getReferenceProperties ( )

Gets all properties of the file reference.

Returns
array

Definition at line 187 of file core/Classes/Resource/FileReference.php.

References FileReference\$propertiesOfFileReference.

getReferenceProperty (   $key)

Gets a property of the file reference.

Parameters
string$keyThe property to be looked up
Returns
mixed
Exceptions
InvalidArgumentException

Definition at line 139 of file core/Classes/Resource/FileReference.php.

getSha1 ( )

Returns the Sha1 of this file

Returns
string

Implements FileInterface.

Definition at line 275 of file core/Classes/Resource/FileReference.php.

getSize ( )

Returns the size of this file

Returns
int

Implements FileInterface.

Definition at line 265 of file core/Classes/Resource/FileReference.php.

getStorage ( )

Get the storage the original file is located in

Returns
ResourceStorage

Implements ResourceInterface.

Definition at line 382 of file core/Classes/Resource/FileReference.php.

Referenced by FileReference\getHashedIdentifier().

getTitle ( )

Returns the title text to this image

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

Definition at line 209 of file core/Classes/Resource/FileReference.php.

References FileReference\getProperty().

getType ( )

Returns the fileType of this file

Returns
int $fileType

Definition at line 335 of file core/Classes/Resource/FileReference.php.

getUid ( )

Returns the uid of this File In Use

Returns
int

Definition at line 255 of file core/Classes/Resource/FileReference.php.

hasProperty (   $key)

Returns true if the given key exists for this file.

Parameters
string$keyThe property to be looked up
Returns
bool

Implements FileInterface.

Definition at line 111 of file core/Classes/Resource/FileReference.php.

References FileReference\getProperties().

Referenced by FileReference\getProperty().

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

Definition at line 462 of file core/Classes/Resource/FileReference.php.

isMissing ( )

Check if file is marked as missing by indexer

Returns
bool

Definition at line 345 of file core/Classes/Resource/FileReference.php.

rename (   $newName)

Renames the fileName in this particular usage.

Parameters
string$newNameThe new name
Exceptions
BadMethodCallException
Returns
FileReference

Implements FileInterface.

Definition at line 429 of file core/Classes/Resource/FileReference.php.

restoreNonNullValuesCallback ( $value,
  $key 
)
protected

Callback to handle the NULL value feature

Parameters
mixed$value
mixed$key

Definition at line 175 of file core/Classes/Resource/FileReference.php.

setContents (   $contents)

Replace the current file contents with the given string

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

Implements FileInterface.

Definition at line 369 of file core/Classes/Resource/FileReference.php.

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

Definition at line 486 of file core/Classes/Resource/FileReference.php.

References FileReference\$propertiesOfFileReference.

Member Data Documentation

$mergedProperties = []
protected

Definition at line 70 of file core/Classes/Resource/FileReference.php.

Referenced by FileReference\getProperties().

$name
protected

Definition at line 54 of file core/Classes/Resource/FileReference.php.

$originalFile
protected
$propertiesOfFileReference
protected
$uidOfFileReference
protected

Definition at line 46 of file core/Classes/Resource/FileReference.php.