‪TYPO3CMS  11.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 ()
 
string getContents ()
 
string getSha1 ()
 
File setContents ($contents)
 
bool null isIndexed ()
 
 updateProperties (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)
 
mixed _getPropertyRaw ($key)
 
MetaDataAspect getMetaData ()
 
- ‪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 ()
 
bool isImage ()
 
bool isMediaFile ()
 
bool isTextFile ()
 
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 Attributes

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

Private Attributes

MetaDataAspect $metaDataAspect
 

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 23 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 44 of file File.php.

References TYPO3\CMS\Core\Resource\AbstractFile\$storage, TYPO3\CMS\Core\Resource\MetaDataAspect\add(), and TYPO3\CMS\Core\Resource\File\getMetaData().

Member Function Documentation

◆ _getPropertyRaw()

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

Only for use in Repositories and indexer

Returns
‪mixed

Definition at line 331 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().

◆ 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 234 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()

bool TYPO3\CMS\Core\Resource\File::checkActionPermission (   $action)

Check if a file operation (= action) is allowed for this file

Parameters
string$action‪can be read, write, delete
Returns
‪bool

Definition at line 219 of file File.php.

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

Referenced by TYPO3\CMS\Filelist\FileList\isEditMetadataAllowed(), TYPO3\CMS\Filelist\FileList\makeEdit(), TYPO3\CMS\Filelist\FileList\makeTranslations(), and TYPO3\CMS\Core\Resource\File\toArray().

◆ getContents()

◆ getMetaData()

◆ 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 93 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). Deprecated since TYPO3 v11, will be removed in TYPO3 v12.0
Returns
‪string|null NULL if file is missing or deleted, the generated url otherwise

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

Definition at line 317 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\Core\Resource\ProcessedFile\getPublicUrl(), 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 122 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 205 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 80 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 150 of file File.php.

Referenced by TYPO3\CMS\Filelist\FileList\isEditMetadataAllowed(), and TYPO3\CMS\Filelist\FileList\makeTranslations().

◆ isMissing()

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

Definition at line 293 of file File.php.

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

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

◆ 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 250 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(), TYPO3\CMS\Core\Resource\Service\MagicImageService\createMagicImage(), TYPO3\CMS\Backend\Controller\File\FileController\flattenFileResultDataValue(), and TYPO3\CMS\Seo\MetaTag\MetaTagGenerator\processSocialImage().

◆ 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 136 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().

◆ setMissing()

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

Definition at line 301 of file File.php.

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

◆ 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 166 of file File.php.

References TYPO3\CMS\Core\Resource\AbstractFile\$properties, 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

◆ $metaDataAspect

MetaDataAspect TYPO3\CMS\Core\Resource\File::$metaDataAspect
private

Definition at line 34 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 30 of file File.php.

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