AbstractFile implements FileInterface
Abstract file representation in the file abstraction layer.
Table of Contents
Interfaces
- FileInterface
- Interface for a file object. This can be any kind of file object, e.g. a processed file (which is not a FAL file), or a file reference object, which is a decorator around a "File" object, but of course without any additional file on the file system.
Properties
- $deleted : bool
- If set to true, this file is regarded as being deleted.
- $name : string
- The file name of this file
- $properties : array<non-empty-string, mixed>
- Various file properties
- $storage : ResourceStorage|null
- The storage this file is located in
Methods
- delete() : bool
- Deletes this file from its storage. This also means that this object becomes useless.
- exists() : bool
- Checks if this file exists. This should normally always return TRUE; it might only return FALSE when this object has been created from an index record without checking for.
- getCombinedIdentifier() : string
- Returns a combined identifier of this file, i.e. the storage UID and the folder identifier separated by a colon ":".
- getContents() : string
- Get the contents of this file
- getCreationTime() : int
- Returns the creation time of the file as Unix timestamp
- getExtension() : string
- Get the extension of this file in a lower-case variant
- getFileType() : FileType
- Returns the fileType of this file basically there are only five main "file types" "audio" "image" "software" "text" "video" "other" see FileType enum
- getForLocalProcessing() : non-empty-string
- Returns a path to a local version of this file to process it locally (e.g. with some system tool).
- getHashedIdentifier() : non-empty-string
- getMimeType() : non-empty-string
- Get the MIME type of this file
- getModificationTime() : int
- Returns the date (as UNIX timestamp) the file was last modified.
- getName() : string
- getNameWithoutExtension() : string
- Returns the basename (the name without extension) of this file.
- getParentFolder() : Folder
- getProperties() : array<non-empty-string, mixed>
- Returns the properties of this object.
- getProperty() : mixed
- Returns a property value
- getPublicUrl() : string|null
- Returns a publicly accessible URL for this file
- getSha1() : non-empty-string
- Returns the Sha1 of this file
- getSize() : int<0, max>
- MUST return the size of the file as unsigned int i.e. 0-max.
- getStorage() : ResourceStorage
- getType() : int
- Returns the fileType of this file basically there are only five main "file types" "audio" "image" "software" "text" "video" "other" see FileType enum
- getUid() : int
- Returns the uid of this file
- hasProperty() : bool
- Returns true if the given property key exists for this file.
- isDeleted() : bool
- Returns TRUE if this file has been deleted
- isImage() : bool
- Useful to find out if this file can be previewed or resized as image.
- isMediaFile() : bool
- Useful to find out if this file has a file extension based on any of the registered media extensions
- isTextFile() : bool
- Useful to find out if this file can be edited.
- isType() : bool
- setContents() : $this
- Replace the current file contents with the given string
- setDeleted() : void
- Marks this file as deleted. This should only be used inside the File Abstraction Layer, as it is a low-level API method.
- setStorage() : $this
- Sets the storage this file is located in. This is only meant for \TYPO3\CMS\Core\Resource-internal usage; don't use it to move files.
- updateProperties() : mixed
- Updates properties of this object.
Properties
$deleted
If set to true, this file is regarded as being deleted.
protected
bool
$deleted
= false
$name
The file name of this file
protected
string
$name
= ''
$properties
Various file properties
protected
array<non-empty-string, mixed>
$properties
= []
Note that all properties, which only the persisted (indexed) files have are stored in this overall properties array only. The only properties which really exist as object properties of the file object are the storage, the identifier, the fileName and the indexing status.
$storage
The storage this file is located in
protected
ResourceStorage|null
$storage
= null
Methods
delete()
Deletes this file from its storage. This also means that this object becomes useless.
public
delete() : bool
Return values
boolexists()
Checks if this file exists. This should normally always return TRUE; it might only return FALSE when this object has been created from an index record without checking for.
public
exists() : bool
Return values
bool —TRUE if this file physically exists
getCombinedIdentifier()
Returns a combined identifier of this file, i.e. the storage UID and the folder identifier separated by a colon ":".
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
Tags
Return values
stringgetCreationTime()
Returns the creation time of the file as Unix timestamp
public
getCreationTime() : int
Tags
Return values
intgetExtension()
Get the extension of this file in a lower-case variant
public
getExtension() : string
Return values
stringgetFileType()
Returns the fileType of this file basically there are only five main "file types" "audio" "image" "software" "text" "video" "other" see FileType enum
public
getFileType() : FileType
Return values
FileTypegetForLocalProcessing()
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 ]) : non-empty-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.
Tags
Return values
non-empty-stringgetHashedIdentifier()
public
getHashedIdentifier() : non-empty-string
Return values
non-empty-stringgetMimeType()
Get the MIME type of this file
public
getMimeType() : non-empty-string
Return values
non-empty-string —mime type
getModificationTime()
Returns the date (as UNIX timestamp) the file was last modified.
public
getModificationTime() : int
Tags
Return values
intgetName()
public
getName() : string
Return values
stringgetNameWithoutExtension()
Returns the basename (the name without extension) of this file.
public
getNameWithoutExtension() : string
Return values
stringgetParentFolder()
public
getParentFolder() : Folder
Return values
FoldergetProperties()
Returns the properties of this object.
public
getProperties() : array<non-empty-string, mixed>
Return values
array<non-empty-string, mixed>getProperty()
Returns a property value
public
getProperty(non-empty-string $key) : mixed
Parameters
- $key : non-empty-string
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 deleted, the generated URL otherwise
getSha1()
Returns the Sha1 of this file
public
getSha1() : non-empty-string
Tags
Return values
non-empty-stringgetSize()
MUST return the size of the file as unsigned int i.e. 0-max.
public
getSize() : int<0, max>
Tags
Return values
int<0, max>getStorage()
public
getStorage() : ResourceStorage
Tags
Return values
ResourceStoragegetType()
Returns the fileType of this file basically there are only five main "file types" "audio" "image" "software" "text" "video" "other" see FileType enum
public
getType() : int
Return values
intgetUid()
Returns the uid of this file
public
getUid() : int
Return values
inthasProperty()
Returns true if the given property key exists for this file.
public
hasProperty(non-empty-string $key) : bool
Parameters
- $key : non-empty-string
Return values
boolisDeleted()
Returns TRUE if this file has been deleted
public
isDeleted() : bool
Return values
boolisImage()
Useful to find out if this file can be previewed or resized as image.
public
isImage() : bool
Return values
bool —true if File has an image-extension according to $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']
isMediaFile()
Useful to find out if this file has a file extension based on any of the registered media extensions
public
isMediaFile() : bool
Return values
bool —true if File is a media-extension according to $GLOBALS['TYPO3_CONF_VARS']['SYS']['mediafile_ext']
isTextFile()
Useful to find out if this file can be edited.
public
isTextFile() : bool
Return values
bool —true if File is a text-based file extension according to $GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext']
isType()
public
isType(FileType $fileType) : bool
Parameters
- $fileType : FileType
Return values
boolsetContents()
Replace the current file contents with the given string
public
setContents(string $contents) : $this
Parameters
- $contents : string
Tags
Return values
$thissetDeleted()
Marks this file as deleted. This should only be used inside the File Abstraction Layer, as it is a low-level API method.
public
setDeleted() : void
setStorage()
Sets the storage this file is located in. This is only meant for \TYPO3\CMS\Core\Resource-internal usage; don't use it to move files.
public
setStorage(ResourceStorage $storage) : $this
Parameters
- $storage : ResourceStorage
Should only be used by other parts of the File API (e.g. drivers after moving a file)
Return values
$thisupdateProperties()
Updates properties of this object.
public
abstract updateProperties(array<string|int, mixed> $properties) : mixed
This method is used to reconstitute settings from the database into this object after being instantiated.
Parameters
- $properties : array<string|int, mixed>