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()  : 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
throws
InvalidArgumentException
throws
FileDoesNotExistException

__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>

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
bool

TRUE if deletion succeeded

getAlternative()

Returns the alternative text to this image

public getAlternative() : string
Tags
todo

Possibly move this to the image domain object instead

Return values
string

getCombinedIdentifier()

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
int

getDescription()

Returns the description text to this file

public getDescription() : string
Tags
todo

Possibly move this to the image domain object instead

Return values
string

getExtension()

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
string

getHashedIdentifier()

Get hashed identifier

public getHashedIdentifier() : string
Return values
string

getIdentifier()

Returns the identifier of the underlying original file

public getIdentifier() : string
Return values
string

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

public getLink() : string
Tags
todo

Move this to the image domain object instead

Return values
string

getMimeType()

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
int

getName()

Returns the name of this file

public getName() : string
Return values
string

getNameWithoutExtension()

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

public getNameWithoutExtension() : string
Return values
string

getOriginalFile()

Gets the original file being referenced.

public getOriginalFile() : File
Return values
File

getProperties()

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
throws
InvalidArgumentException

getPublicUrl()

Returns a publicly accessible URL for this file

public getPublicUrl() : 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
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
throws
InvalidArgumentException

getSha1()

Returns the Sha1 of this file

public getSha1() : string
Return values
string

getSize()

Returns the size of this file

public getSize() : int
Return values
int

getTitle()

Returns the title text to this image

public getTitle() : string
Tags
todo

Possibly move this to the image domain object instead

Return values
string

getType()

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
int

hasProperty()

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
bool

isIndexed()

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
bool

isMissing()

Check if file is marked as missing by indexer

public isMissing() : bool
Return values
bool

rename()

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
File

setContents()

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

        
On this page

Search results