‪TYPO3CMS  10.4
TYPO3\CMS\Core\Resource\AbstractFile Class Reference
Inheritance diagram for TYPO3\CMS\Core\Resource\AbstractFile:
TYPO3\CMS\Core\Resource\FileInterface TYPO3\CMS\Core\Resource\ResourceInterface TYPO3\CMS\Core\Resource\File TYPO3\CMS\Core\Resource\ProcessedFile

Public Member Functions

bool hasProperty ($key)
 
mixed getProperty ($key)
 
array getProperties ()
 
string getIdentifier ()
 
string getHashedIdentifier ()
 
string getName ()
 
string getNameWithoutExtension ()
 
int null getSize ()
 
int getUid ()
 
string getSha1 ()
 
int getCreationTime ()
 
int getModificationTime ()
 
string getExtension ()
 
string getMimeType ()
 
int getType ()
 
bool isImage ()
 
bool isMediaFile ()
 
bool isTextFile ()
 
string getContents ()
 
File setContents ($contents)
 
ResourceStorage getStorage ()
 
bool exists ()
 
File setStorage (ResourceStorage $storage)
 
File setIdentifier ($identifier)
 
string getCombinedIdentifier ()
 
bool delete ()
 
 setDeleted ()
 
bool isDeleted ()
 
FileInterface rename ($newName, $conflictMode=DuplicationBehavior::RENAME)
 
File copyTo (Folder $targetFolder, $targetFileName=null, $conflictMode=DuplicationBehavior::RENAME)
 
File moveTo (Folder $targetFolder, $targetFileName=null, $conflictMode=DuplicationBehavior::RENAME)
 
string null getPublicUrl ($relativeToCurrentScript=false)
 
string getForLocalProcessing ($writable=true)
 
 updateProperties (array $properties)
 
FolderInterface getParentFolder ()
 
- ‪Public Member Functions inherited from ‪TYPO3\CMS\Core\Resource\FileInterface
bool isIndexed ()
 
array toArray ()
 

Public Attributes

const FILETYPE_UNKNOWN = 0
 
const FILETYPE_TEXT = 1
 
const FILETYPE_IMAGE = 2
 
const FILETYPE_AUDIO = 3
 
const FILETYPE_VIDEO = 4
 
const FILETYPE_APPLICATION = 5
 

Protected Attributes

array $properties
 
ResourceStorage $storage
 
string $identifier
 
string $name
 
bool $deleted = false
 

Detailed Description

Abstract file representation in the file abstraction layer.

Definition at line 25 of file AbstractFile.php.

Member Function Documentation

◆ copyTo()

File TYPO3\CMS\Core\Resource\AbstractFile::copyTo ( Folder  $targetFolder,
  $targetFileName = null,
  $conflictMode = DuplicationBehavior::RENAME 
)

Copies this file into a target folder

Parameters
Folder$targetFolderFolder to copy file into.
string$targetFileName‪an optional destination fileName
string$conflictMode‪a value of the \TYPO3\CMS\Core\Resource\DuplicationBehavior enumeration
Exceptions

Definition at line 521 of file AbstractFile.php.

References TYPO3\CMS\Core\Resource\ResourceStorage\copyFile(), and TYPO3\CMS\Core\Resource\Folder\getStorage().

◆ delete()

bool TYPO3\CMS\Core\Resource\AbstractFile::delete ( )

Deletes this file from its storage. This also means that this object becomes useless.

Returns
‪bool TRUE if deletion succeeded

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 462 of file AbstractFile.php.

References TYPO3\CMS\Core\Resource\ResourceStorage\deleteFile(), and TYPO3\CMS\Core\Resource\AbstractFile\getStorage().

◆ exists()

bool TYPO3\CMS\Core\Resource\AbstractFile::exists ( )

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.

Returns
‪bool TRUE if this file physically exists

Reimplemented in TYPO3\CMS\Core\Resource\ProcessedFile.

Definition at line 405 of file AbstractFile.php.

References TYPO3\CMS\Core\Resource\AbstractFile\getIdentifier().

◆ getCombinedIdentifier()

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

Returns a combined identifier of this file, i.e. the storage UID and the folder identifier separated by a colon ":".

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

Definition at line 447 of file AbstractFile.php.

References TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger(), TYPO3\CMS\Core\Resource\AbstractFile\getIdentifier(), TYPO3\CMS\Core\Resource\AbstractFile\getStorage(), and TYPO3\CMS\Core\Resource\ResourceStorage\getUid().

Referenced by TYPO3\CMS\Core\Resource\File\calculateChecksum(), TYPO3\CMS\Impexp\Export\export_addSysFile(), TYPO3\CMS\Core\Utility\File\ExtendedFileUtility\func_upload(), and TYPO3\CMS\Core\Resource\File\toArray().

◆ getContents()

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

◆ getCreationTime()

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

Returns the creation time of the file as Unix timestamp

Exceptions

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 227 of file AbstractFile.php.

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

◆ getExtension()

◆ getForLocalProcessing()

string TYPO3\CMS\Core\Resource\AbstractFile::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.
Exceptions

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 577 of file AbstractFile.php.

References TYPO3\CMS\Core\Resource\ResourceStorage\getFileForLocalProcessing(), and TYPO3\CMS\Core\Resource\AbstractFile\getStorage().

Referenced by TYPO3\CMS\Impexp\Export\export_addSysFile(), TYPO3\CMS\Core\Resource\Index\Indexer\extractRequiredMetaData(), TYPO3\CMS\Core\Resource\Index\MetaDataRepository\findByFile(), TYPO3\CMS\Core\Resource\Processing\LocalPreviewHelper\generatePreviewFromFile(), and TYPO3\CMS\Core\Resource\Processing\LocalCropScaleMaskHelper\process().

◆ getHashedIdentifier()

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

Get hashed identifier

Returns
‪string

Implements TYPO3\CMS\Core\Resource\ResourceInterface.

Definition at line 151 of file AbstractFile.php.

◆ getIdentifier()

◆ getMimeType()

◆ getModificationTime()

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

Returns the date (as UNIX timestamp) the file was last modified.

Exceptions

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 241 of file AbstractFile.php.

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

Referenced by TYPO3\CMS\Core\Resource\Processing\AbstractTask\getChecksumData().

◆ getName()

◆ getNameWithoutExtension()

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

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

Returns
‪string

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 173 of file AbstractFile.php.

References TYPO3\CMS\Core\Resource\AbstractFile\getName(), and TYPO3\CMS\Core\Utility\PathUtility\pathinfo().

Referenced by TYPO3\CMS\Core\Resource\Processing\AbstractGraphicalTask\getTargetFilename().

◆ getParentFolder()

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

◆ getProperties()

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

Returns the properties of this object.

Returns
‪array

Reimplemented in TYPO3\CMS\Core\Resource\File.

Definition at line 131 of file AbstractFile.php.

References TYPO3\CMS\Core\Resource\AbstractFile\$properties.

◆ getProperty()

mixed TYPO3\CMS\Core\Resource\AbstractFile::getProperty (   $key)

◆ getPublicUrl()

string null TYPO3\CMS\Core\Resource\AbstractFile::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 deleted, the generated URL otherwise

Implements TYPO3\CMS\Core\Resource\FileInterface.

Reimplemented in TYPO3\CMS\Core\Resource\ProcessedFile, and TYPO3\CMS\Core\Resource\File.

Definition at line 559 of file AbstractFile.php.

References TYPO3\CMS\Core\Resource\ResourceStorage\getPublicUrl(), and TYPO3\CMS\Core\Resource\AbstractFile\getStorage().

◆ getSha1()

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

Returns the Sha1 of this file

Exceptions

Implements TYPO3\CMS\Core\Resource\FileInterface.

Reimplemented in TYPO3\CMS\Core\Resource\File.

Definition at line 213 of file AbstractFile.php.

References TYPO3\CMS\Core\Resource\AbstractFile\getStorage(), and TYPO3\CMS\Core\Resource\ResourceStorage\hashFile().

◆ getSize()

◆ getStorage()

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

Get the storage this file is located in

Returns
ResourceStorage
Exceptions

Implements TYPO3\CMS\Core\Resource\ResourceInterface.

Definition at line 390 of file AbstractFile.php.

References TYPO3\CMS\Core\Resource\AbstractFile\$storage.

Referenced by TYPO3\CMS\Core\Resource\ProcessedFile\__construct(), TYPO3\CMS\Backend\Resource\Processing\DeferredBackendImageProcessor\canProcessTask(), TYPO3\CMS\Core\Resource\File\checkActionPermission(), TYPO3\CMS\Core\Resource\Processing\LocalImageProcessor\checkForExistingTargetFile(), TYPO3\CMS\Core\Resource\AbstractFile\delete(), TYPO3\CMS\Impexp\Export\export_addSysFile(), TYPO3\CMS\Core\Resource\Service\ExtractorService\extractMetaData(), TYPO3\CMS\Core\Resource\Index\MetaDataRepository\findByFile(), TYPO3\CMS\Core\Resource\AbstractFile\getCombinedIdentifier(), TYPO3\CMS\Core\Resource\File\getContents(), TYPO3\CMS\Core\Resource\AbstractFile\getContents(), TYPO3\CMS\Core\Resource\AbstractFile\getForLocalProcessing(), TYPO3\CMS\Core\Resource\AbstractFile\getMimeType(), TYPO3\CMS\Core\Resource\AbstractFile\getParentFolder(), TYPO3\CMS\Core\Resource\File\getPublicUrl(), TYPO3\CMS\Core\Resource\AbstractFile\getPublicUrl(), TYPO3\CMS\Core\Resource\ProcessedFile\getPublicUrl(), TYPO3\CMS\Core\Resource\AbstractFile\getSha1(), TYPO3\CMS\Core\Resource\AbstractFile\getSize(), TYPO3\CMS\Core\Resource\Index\FileIndexRepository\hasIndexRecord(), TYPO3\CMS\Core\Resource\File\process(), TYPO3\CMS\Core\Resource\AbstractFile\rename(), TYPO3\CMS\Core\Resource\File\setContents(), TYPO3\CMS\Core\Resource\AbstractFile\setContents(), TYPO3\CMS\Core\Resource\File\toArray(), TYPO3\CMS\Core\Resource\ProcessedFile\toArray(), and TYPO3\CMS\Core\Resource\Index\FileIndexRepository\update().

◆ getType()

◆ getUid()

◆ hasProperty()

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

Returns true if the given property key exists for this file.

Parameters
string$key
Returns
‪bool

Implements TYPO3\CMS\Core\Resource\FileInterface.

Reimplemented in TYPO3\CMS\Core\Resource\File.

Definition at line 107 of file AbstractFile.php.

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

◆ isDeleted()

bool TYPO3\CMS\Core\Resource\AbstractFile::isDeleted ( )

Returns TRUE if this file has been deleted

Returns
‪bool

Definition at line 490 of file AbstractFile.php.

References TYPO3\CMS\Core\Resource\AbstractFile\$deleted.

◆ isImage()

bool TYPO3\CMS\Core\Resource\AbstractFile::isImage ( )

Useful to find out if this file can be previewed or resized as image.

Returns
‪bool true if File has an image-extension according to $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']

Definition at line 323 of file AbstractFile.php.

References $GLOBALS, TYPO3\CMS\Core\Resource\AbstractFile\getExtension(), and TYPO3\CMS\Core\Resource\AbstractFile\getSize().

Referenced by TYPO3\CMS\Core\Resource\Index\Indexer\extractRequiredMetaData(), TYPO3\CMS\Core\Resource\Processing\LocalPreviewHelper\generatePreviewFromFile(), and TYPO3\CMS\Filelist\FileFacade\getIsImage().

◆ isMediaFile()

bool TYPO3\CMS\Core\Resource\AbstractFile::isMediaFile ( )

Useful to find out if this file has a file extension based on any of the registered media extensions

Returns
‪bool true if File is a media-extension according to $GLOBALS['TYPO3_CONF_VARS']['SYS']['mediafile_ext']

Definition at line 332 of file AbstractFile.php.

References $GLOBALS, TYPO3\CMS\Core\Resource\AbstractFile\getExtension(), and TYPO3\CMS\Core\Resource\AbstractFile\getSize().

◆ isTextFile()

bool TYPO3\CMS\Core\Resource\AbstractFile::isTextFile ( )

Useful to find out if this file can be edited.

Returns
‪bool true if File is a text-based file extension according to $GLOBALS['TYPO3_CONF_VARS']['SYS']['textfile_ext']

Definition at line 342 of file AbstractFile.php.

References $GLOBALS, and TYPO3\CMS\Core\Resource\AbstractFile\getExtension().

Referenced by TYPO3\CMS\Filelist\FileFacade\getIsEditable().

◆ moveTo()

File TYPO3\CMS\Core\Resource\AbstractFile::moveTo ( Folder  $targetFolder,
  $targetFileName = null,
  $conflictMode = DuplicationBehavior::RENAME 
)

Moves the file into the target folder

Parameters
Folder$targetFolderFolder to move file into.
string$targetFileName‪an optional destination fileName
string$conflictMode‪a value of the \TYPO3\CMS\Core\Resource\DuplicationBehavior enumeration
Exceptions

Definition at line 539 of file AbstractFile.php.

References TYPO3\CMS\Core\Resource\Folder\getStorage(), and TYPO3\CMS\Core\Resource\ResourceStorage\moveFile().

◆ rename()

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

Renames this file.

Parameters
string$newName‪The new file name
string$conflictMode
Returns
FileInterface

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 503 of file AbstractFile.php.

References TYPO3\CMS\Core\Resource\AbstractFile\getStorage(), and TYPO3\CMS\Core\Resource\ResourceStorage\renameFile().

◆ setContents()

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

Replace the current file contents with the given string

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

Implements TYPO3\CMS\Core\Resource\FileInterface.

Reimplemented in TYPO3\CMS\Core\Resource\ProcessedFile, and TYPO3\CMS\Core\Resource\File.

Definition at line 371 of file AbstractFile.php.

References TYPO3\CMS\Core\Resource\AbstractFile\getStorage(), and TYPO3\CMS\Core\Resource\ResourceStorage\setFileContents().

◆ setDeleted()

TYPO3\CMS\Core\Resource\AbstractFile::setDeleted ( )

Marks this file as deleted. This should only be used inside the File Abstraction Layer, as it is a low-level API method.

Definition at line 480 of file AbstractFile.php.

◆ setIdentifier()

File TYPO3\CMS\Core\Resource\AbstractFile::setIdentifier (   $identifier)

Set the identifier of this file

Should only be used by other parts of the File API (e.g. drivers after moving a file)

Parameters
string$identifier
Returns
File

Definition at line 435 of file AbstractFile.php.

References TYPO3\CMS\Core\Resource\AbstractFile\$identifier.

Referenced by TYPO3\CMS\Core\Resource\ResourceStorage\updateProcessedFile().

◆ setStorage()

File TYPO3\CMS\Core\Resource\AbstractFile::setStorage ( ResourceStorage  $storage)

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.

Should only be used by other parts of the File API (e.g. drivers after moving a file)

Parameters
ResourceStorage$storage
Returns
File

Definition at line 421 of file AbstractFile.php.

References TYPO3\CMS\Core\Resource\AbstractFile\$storage, and TYPO3\CMS\Core\Resource\ResourceStorage\getUid().

Referenced by TYPO3\CMS\Core\Resource\ProcessedFileRepository\createDomainObject().

◆ updateProperties()

TYPO3\CMS\Core\Resource\AbstractFile::updateProperties ( array  $properties)
abstract

Updates properties of this object. This method is used to reconstitute settings from the database into this object after being instantiated.

Parameters
array$properties

Reimplemented in TYPO3\CMS\Core\Resource\ProcessedFile, and TYPO3\CMS\Core\Resource\File.

Member Data Documentation

◆ $deleted

bool TYPO3\CMS\Core\Resource\AbstractFile::$deleted = false
protected

If set to true, this file is regarded as being deleted.

Definition at line 61 of file AbstractFile.php.

Referenced by TYPO3\CMS\Core\Resource\AbstractFile\isDeleted().

◆ $identifier

string TYPO3\CMS\Core\Resource\AbstractFile::$identifier
protected

The identifier of this file to identify it on the storage. On some drivers, this is the path to the file, but drivers could also just provide any other unique identifier for this file on the specific storage.

Definition at line 49 of file AbstractFile.php.

Referenced by TYPO3\CMS\Core\Resource\AbstractFile\getIdentifier(), and TYPO3\CMS\Core\Resource\AbstractFile\setIdentifier().

◆ $name

◆ $properties

array TYPO3\CMS\Core\Resource\AbstractFile::$properties
protected

Various file 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.

Definition at line 35 of file AbstractFile.php.

Referenced by TYPO3\CMS\Backend\Controller\File\FileController\getFileEditRedirect(), TYPO3\CMS\Core\Resource\AbstractFile\getProperties(), TYPO3\CMS\Core\Resource\ProcessedFile\toArray(), TYPO3\CMS\Core\Resource\File\updateProperties(), and TYPO3\CMS\Core\Resource\ProcessedFile\updateProperties().

◆ $storage

◆ FILETYPE_APPLICATION

const TYPO3\CMS\Core\Resource\AbstractFile::FILETYPE_APPLICATION = 5

◆ FILETYPE_AUDIO

const TYPO3\CMS\Core\Resource\AbstractFile::FILETYPE_AUDIO = 3

◆ FILETYPE_IMAGE

◆ FILETYPE_TEXT

◆ FILETYPE_UNKNOWN

const TYPO3\CMS\Core\Resource\AbstractFile::FILETYPE_UNKNOWN = 0

◆ FILETYPE_VIDEO

const TYPO3\CMS\Core\Resource\AbstractFile::FILETYPE_VIDEO = 4