‪TYPO3CMS  ‪main
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=[])
 
 getProperty (string $key)
 
 hasProperty ($key)
 
 getProperties ()
 
 getContents ()
 
non empty string getSha1 ()
 
$this setContents (string $contents)
 
 isIndexed ()
 
 updateProperties (array $properties)
 
array getUpdatedProperties ()
 
bool checkActionPermission ($action)
 
string calculateChecksum ()
 
 process (string $taskType, array $configuration)
 
array< non-empty-string, toArray():array { $array=['id'=> $this getCombinedIdentifier ()
 
bool isMissing ()
 
 setMissing ($missing)
 
 getPublicUrl ()
 
mixed _getPropertyRaw ($key)
 
 getMetaData ()
 
- ‪Public Member Functions inherited from ‪TYPO3\CMS\Core\Resource\AbstractFile
 hasProperty (string $key)
 
 getIdentifier ()
 
non empty string getHashedIdentifier ()
 
 getName ()
 
 getNameWithoutExtension ()
 
int< 0, getSize():int { if( $this->deleted) { throw new \RuntimeException( 'File has been deleted.', 1329821480);} if(empty( $this->properties[ 'size'])) { $fileInfo=$this-> getStorage () -> getFileInfoByIdentifier($this->getIdentifier(), ['size'])
 
return MathUtility::canBeInterpretedAsInteger($size) ?(int) $size int getUid ()
 
 getCreationTime ()
 
 getModificationTime ()
 
 getExtension ()
 
non empty string getMimeType ()
 
int getType ()
 
 isType (FileType $fileType)
 
bool isImage ()
 
bool isMediaFile ()
 
bool isTextFile ()
 
 getStorage ()
 
bool exists ()
 
$this setStorage (ResourceStorage $storage)
 
$this setIdentifier ($identifier)
 
 delete ()
 
 setDeleted ()
 
bool isDeleted ()
 
 rename (string $newName, $conflictMode=DuplicationBehavior::RENAME)
 
File copyTo (Folder $targetFolder, $targetFileName=null, $conflictMode=DuplicationBehavior::RENAME)
 
File moveTo (Folder $targetFolder, $targetFileName=null, $conflictMode=DuplicationBehavior::RENAME)
 
non empty string getForLocalProcessing (bool $writable=true)
 
 getParentFolder ()
 

Public Attributes

array< non-empty-string, toArray():array { $array=['id'=> $this foreach($this->properties as $key=> $value) $stat = $this->getStorage()->getFileInfo($this)
 
foreach($stat as $key=> $value) return $array
 
- ‪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
 
array< non-empty-string, function getProperties() { return $this-> properties
 
 $size = array_pop($fileInfo)
 
 else
 

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
 

Detailed Description

File representation in the file abstraction layer.

Definition at line 25 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.

Definition at line 42 of file File.php.

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

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 314 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 223 of file File.php.

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

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

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

Referenced by TYPO3\CMS\Backend\Form\Element\LinkElement\getLinkExplanation(), TYPO3\CMS\Filelist\FileList\getSortingValueForFile(), and TYPO3\CMS\Filelist\FileList\isEditMetadataAllowed().

◆ getCombinedIdentifier()

array<non-empty-string, toArray(): array { $array = [ 'id' => $this TYPO3\CMS\Core\Resource\File::getCombinedIdentifier ( )

Returns an array representation of the file. (This is used by the generic listing module vidi when displaying file records.)

Returns
‪array<non-empty-string, mixed> Array of main data of the file. Don't rely on all data to be present here, it's just a selection of the most relevant information.

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

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

Referenced by TYPO3\CMS\Core\Resource\File\calculateChecksum(), and TYPO3\CMS\Core\Resource\FileReference\getCombinedIdentifier().

◆ getContents()

◆ getMetaData()

◆ getProperties()

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

◆ getProperty()

◆ getPublicUrl()

TYPO3\CMS\Core\Resource\File::getPublicUrl ( )

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.

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

Definition at line 301 of file File.php.

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

Referenced by TYPO3\CMS\Core\Resource\File\getPublicUrl(), TYPO3\CMS\Core\Resource\FileReference\getPublicUrl(), TYPO3\CMS\Core\Resource\ProcessedFile\getPublicUrl(), and TYPO3\CMS\Core\Resource\AbstractFile\getPublicUrl().

◆ getSha1()

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

Gets SHA1 hash.

Returns
‪non-empty-string

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

Definition at line 114 of file File.php.

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

Referenced by TYPO3\CMS\Core\Resource\ProcessedFile\__construct(), and TYPO3\CMS\Core\Resource\FileReference\getSha1().

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

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

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

◆ hasProperty()

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

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

Parameters
string$key

Definition at line 76 of file File.php.

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

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

◆ isIndexed()

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

Returns TRUE if this file is indexed

Definition at line 139 of file File.php.

Referenced by TYPO3\CMS\Filelist\Dto\ResourceView\canEditMetadata(), and TYPO3\CMS\Filelist\FileList\isEditMetadataAllowed().

◆ isMissing()

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

◆ process()

TYPO3\CMS\Core\Resource\File::process ( string  $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

Definition at line 238 of file File.php.

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

Referenced by TYPO3\CMS\Backend\Controller\File\FileController\flattenFileResultDataValue().

◆ setContents()

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

Replace the current file contents with the given string

Returns
‪$this

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

Definition at line 127 of file File.php.

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

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

◆ setMissing()

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

Definition at line 289 of file File.php.

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

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

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

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

◆ $array

foreach ( $stat as $key=> $value) return TYPO3\CMS\Core\Resource\File::$array

Definition at line 275 of file File.php.

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

◆ $metaDataAspect

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

Definition at line 36 of file File.php.

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

◆ $stat

array<non-empty-string, toArray(): array { $array = [ 'id' => $this foreach ( $this->properties as $key=> $value) TYPO3\CMS\Core\Resource\File::$stat = $this->getStorage()->getFileInfo($this)

Definition at line 271 of file File.php.

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

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