‪TYPO3CMS  9.5
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 ()
 
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 23 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 492 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 ( )

◆ 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 376 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 418 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(), 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 225 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 548 of file AbstractFile.php.

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

Referenced by TYPO3\CMS\Core\DataHandling\DataHandler\checkValue_group_select_file(), 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 149 of file AbstractFile.php.

Referenced by TYPO3\CMS\Core\Resource\OnlineMedia\Processing\PreviewProcessing\processFile().

◆ getIdentifier()

◆ getMimeType()

◆ getModificationTime()

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

◆ getName()

◆ getNameWithoutExtension()

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

◆ 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 129 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 530 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 211 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 361 of file AbstractFile.php.

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

Referenced by TYPO3\CMS\Core\Resource\ProcessedFile\__construct(), 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\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\Utility\BackendUtility\getFlashMessageForMissingFile(), 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 105 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 461 of file AbstractFile.php.

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

◆ 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 510 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 474 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 342 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 451 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 406 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 392 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 intantiated.

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 59 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 47 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 33 of file AbstractFile.php.

Referenced by TYPO3\CMS\Core\Resource\File\_updateMetaDataProperties(), 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

ResourceStorage TYPO3\CMS\Core\Resource\AbstractFile::$storage
protected

◆ 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