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

Public Member Functions

 __construct (array $fileData, ResourceStorage $storage, array $metaData=[])
 
mixed getProperty ($key)
 
bool hasProperty ($key)
 
array getProperties ()
 
array _getMetaData ()
 
string getContents ()
 
string getSha1 ()
 
File setContents ($contents)
 
bool null isIndexed ()
 
 updateProperties (array $properties)
 
 _updateMetaDataProperties (array $properties)
 
array getUpdatedProperties ()
 
bool checkActionPermission ($action)
 
string calculateChecksum ()
 
ProcessedFile process ($taskType, array $configuration)
 
array toArray ()
 
bool isMissing ()
 
 setMissing ($missing)
 
string null getPublicUrl ($relativeToCurrentScript=false)
 
 setIndexingInProgess ($indexingState)
 
mixed _getPropertyRaw ($key)
 
- ‪Public Member Functions inherited from ‪TYPO3\CMS\Core\Resource\AbstractFile
string getIdentifier ()
 
string getHashedIdentifier ()
 
string getName ()
 
string getNameWithoutExtension ()
 
int null getSize ()
 
int getUid ()
 
int getCreationTime ()
 
int getModificationTime ()
 
string getExtension ()
 
string getMimeType ()
 
int getType ()
 
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 getForLocalProcessing ($writable=true)
 
FolderInterface getParentFolder ()
 

Protected Member Functions

 loadMetaData ()
 
Index MetaDataRepository getMetaDataRepository ()
 
Index FileIndexRepository getFileIndexRepository ()
 

Protected Attributes

bool $metaDataLoaded = false
 
array $metaDataProperties = array( )
 
bool $indexingInProgress = false
 
array $updatedProperties = array( )
 
- ‪Protected Attributes inherited from ‪TYPO3\CMS\Core\Resource\AbstractFile
array $properties
 
ResourceStorage $storage
 
string $identifier
 
string $name
 
bool $deleted = false
 

Additional Inherited Members

- ‪Public Attributes inherited from ‪TYPO3\CMS\Core\Resource\AbstractFile
const FILETYPE_UNKNOWN = 0
 
const FILETYPE_TEXT = 1
 
const FILETYPE_IMAGE = 2
 
const FILETYPE_AUDIO = 3
 
const FILETYPE_VIDEO = 4
 
const FILETYPE_APPLICATION = 5
 

Detailed Description

File representation in the file abstraction layer.

Definition at line 22 of file File.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Resource\File::__construct ( array  $fileData,
ResourceStorage  $storage,
array  $metaData = [] 
)

Constructor for a file object. Should normally not be used directly, use the corresponding factory methods instead.

Parameters
array$fileData
ResourceStorage$storage
array$metaData

Definition at line 53 of file File.php.

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

Member Function Documentation

◆ _getMetaData()

◆ _getPropertyRaw()

mixed TYPO3\CMS\Core\Resource\File::_getPropertyRaw (   $key)
Parameters
$key

Only for use in Repositories and indexer

Returns
‪mixed

Definition at line 398 of file File.php.

Referenced by TYPO3\CMS\Core\Resource\Index\FileIndexRepository\add(), TYPO3\CMS\Core\Resource\Index\FileIndexRepository\hasIndexRecord(), and TYPO3\CMS\Core\Resource\Index\FileIndexRepository\update().

◆ _updateMetaDataProperties()

TYPO3\CMS\Core\Resource\File::_updateMetaDataProperties ( array  $properties)

Updates MetaData properties

Do not use outside the FileAbstraction Layer classes

Parameters
array$properties

Definition at line 238 of file File.php.

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

Referenced by TYPO3\CMS\Core\Resource\Index\Indexer\extractMetaData(), and TYPO3\CMS\Core\Resource\Index\Indexer\extractRequiredMetaData().

◆ calculateChecksum()

string TYPO3\CMS\Core\Resource\File::calculateChecksum ( )

Creates a MD5 hash checksum based on the combined identifier of the file, the files' mimetype and the systems' encryption key. used to generate a thumbnail, and this hash is checked if valid

Returns
‪string the MD5 hash

Definition at line 277 of file File.php.

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

Referenced by TYPO3\CMS\Core\Resource\File\toArray().

◆ checkActionPermission()

◆ getContents()

◆ getFileIndexRepository()

Index FileIndexRepository TYPO3\CMS\Core\Resource\File::getFileIndexRepository ( )
protected
Returns
Index\FileIndexRepository

Definition at line 379 of file File.php.

◆ getMetaDataRepository()

Index MetaDataRepository TYPO3\CMS\Core\Resource\File::getMetaDataRepository ( )
protected
Returns
Index\MetaDataRepository

Definition at line 371 of file File.php.

Referenced by TYPO3\CMS\Core\Resource\File\loadMetaData().

◆ getProperties()

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

Returns the properties of this object.

Returns
‪array

Reimplemented from TYPO3\CMS\Core\Resource\AbstractFile.

Definition at line 103 of file File.php.

References TYPO3\CMS\Core\Resource\File\_getMetaData().

Referenced by TYPO3\CMS\Core\Resource\Index\FileIndexRepository\add(), and TYPO3\CMS\Core\Resource\Index\FileIndexRepository\update().

◆ getProperty()

◆ getPublicUrl()

string null TYPO3\CMS\Core\Resource\File::getPublicUrl (   $relativeToCurrentScript = false)

Returns a publicly accessible URL for this file When file is marked as missing or deleted no url is returned

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 missing or deleted, the generated url otherwise

Reimplemented from TYPO3\CMS\Core\Resource\AbstractFile.

Definition at line 360 of file File.php.

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

Referenced by TYPO3\CMS\Extbase\Service\ImageService\getCompatibilityImageResourceValues(), TYPO3\CMS\Core\Resource\ProcessedFile\getPublicUrl(), TYPO3\CMS\Impexp\Import\setRelations_db(), and TYPO3\CMS\Core\Resource\File\toArray().

◆ getSha1()

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

Gets SHA1 hash.

Returns
‪string

Reimplemented from TYPO3\CMS\Core\Resource\AbstractFile.

Definition at line 140 of file File.php.

Referenced by TYPO3\CMS\Core\Resource\ProcessedFile\__construct().

◆ getUpdatedProperties()

array TYPO3\CMS\Core\Resource\File::getUpdatedProperties ( )

Returns the names of all properties that have been updated in this record

Returns
‪array

Definition at line 248 of file File.php.

References TYPO3\CMS\Core\Resource\File\$updatedProperties.

Referenced by TYPO3\CMS\Core\Resource\Index\FileIndexRepository\update().

◆ hasProperty()

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

Checks if the file has a (metadata) property which can be retrieved by "getProperty"

Parameters
string$key
Returns
‪bool

Reimplemented from TYPO3\CMS\Core\Resource\AbstractFile.

Definition at line 90 of file File.php.

References TYPO3\CMS\Core\Resource\File\_getMetaData().

◆ isIndexed()

bool null TYPO3\CMS\Core\Resource\File::isIndexed ( )

Returns TRUE if this file is indexed

Returns
‪bool|null

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 168 of file File.php.

Referenced by TYPO3\CMS\Filelist\FileList\linkWrapFile().

◆ isMissing()

bool TYPO3\CMS\Core\Resource\File::isMissing ( )
Returns
‪bool

Definition at line 336 of file File.php.

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

Referenced by TYPO3\CMS\Core\Resource\File\getPublicUrl().

◆ loadMetaData()

TYPO3\CMS\Core\Resource\File::loadMetaData ( )
protected

Loads MetaData from Repository

Definition at line 176 of file File.php.

References TYPO3\CMS\Core\Resource\File\getMetaDataRepository().

Referenced by TYPO3\CMS\Core\Resource\File\_getMetaData().

◆ process()

ProcessedFile TYPO3\CMS\Core\Resource\File::process (   $taskType,
array  $configuration 
)

Returns a modified version of the file.

Parameters
string$taskType‪The task type of this processing
array$configuration‪the processing configuration, see manual for that
Returns
ProcessedFile The processed file

Definition at line 293 of file File.php.

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

Referenced by TYPO3\CMS\Extbase\Service\ImageService\applyProcessingInstructions(), and TYPO3\CMS\Backend\Backend\Avatar\DefaultAvatarProvider\getImage().

◆ setContents()

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

Replace the current file contents with the given string

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

Reimplemented from TYPO3\CMS\Core\Resource\AbstractFile.

Definition at line 154 of file File.php.

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

Referenced by TYPO3\CMS\Core\Resource\FileReference\setContents().

◆ setIndexingInProgess()

TYPO3\CMS\Core\Resource\File::setIndexingInProgess (   $indexingState)
Parameters
bool$indexingState

Only for usage in Indexer

Definition at line 388 of file File.php.

◆ setMissing()

TYPO3\CMS\Core\Resource\File::setMissing (   $missing)
Parameters
bool$missing

Definition at line 344 of file File.php.

References TYPO3\CMS\Core\Resource\File\updateProperties().

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

◆ toArray()

◆ updateProperties()

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

Updates the properties of this file, e.g. after re-indexing or moving it. By default, only properties that exist as a key in the $properties array are overwritten. If you want to explicitly unset a property, set the corresponding key to NULL in the array.

NOTE: This method should not be called from outside the File Abstraction Layer (FAL)!

Parameters
array$properties

Reimplemented from TYPO3\CMS\Core\Resource\AbstractFile.

Definition at line 197 of file File.php.

References TYPO3\CMS\Core\Resource\AbstractFile\$properties, TYPO3\CMS\Core\Resource\ResourceFactory\getInstance(), TYPO3\CMS\Core\Resource\ResourceFactory\getStorageObject(), and TYPO3\CMS\Core\Resource\AbstractFile\getType().

Referenced by TYPO3\CMS\Core\Resource\Index\FileIndexRepository\add(), TYPO3\CMS\Core\Resource\Index\Indexer\processChangedAndNewFiles(), TYPO3\CMS\Core\Resource\File\setMissing(), and TYPO3\CMS\Core\Resource\Index\Indexer\updateIndexEntry().

Member Data Documentation

◆ $indexingInProgress

bool TYPO3\CMS\Core\Resource\File::$indexingInProgress = false
protected

Set to TRUE while this file is being indexed - used to prevent some endless loops

Definition at line 36 of file File.php.

◆ $metaDataLoaded

bool TYPO3\CMS\Core\Resource\File::$metaDataLoaded = false
protected

Definition at line 26 of file File.php.

◆ $metaDataProperties

array TYPO3\CMS\Core\Resource\File::$metaDataProperties = array( )
protected

Definition at line 30 of file File.php.

Referenced by TYPO3\CMS\Core\Resource\File\_getMetaData().

◆ $updatedProperties

array TYPO3\CMS\Core\Resource\File::$updatedProperties = array( )
protected

Contains the names of all properties that have been update since the instantiation of this object

Definition at line 43 of file File.php.

Referenced by TYPO3\CMS\Core\Resource\File\getUpdatedProperties().