TYPO3 CMS  TYPO3_7-6
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 ($key)
 
 hasProperty ($key)
 
 getProperties ()
 
 _getMetaData ()
 
 getContents ()
 
 getSha1 ()
 
 setContents ($contents)
 
 isIndexed ()
 
 updateProperties (array $properties)
 
 _updateMetaDataProperties (array $properties)
 
 getUpdatedProperties ()
 
 checkActionPermission ($action)
 
 calculateChecksum ()
 
 process ($taskType, array $configuration)
 
 toArray ()
 
 isMissing ()
 
 setMissing ($missing)
 
 getPublicUrl ($relativeToCurrentScript=false)
 
 setIndexingInProgess ($indexingState)
 
 _getPropertyRaw ($key)
 
- Public Member Functions inherited from TYPO3\CMS\Core\Resource\AbstractFile
 hasProperty ($key)
 
 getProperty ($key)
 
 getProperties ()
 
 getIdentifier ()
 
 getHashedIdentifier ()
 
 getName ()
 
 getNameWithoutExtension ()
 
 getSize ()
 
 getUid ()
 
 getSha1 ()
 
 getCreationTime ()
 
 getModificationTime ()
 
 getExtension ()
 
 getMimeType ()
 
 getType ()
 
 getContents ()
 
 setContents ($contents)
 
 getStorage ()
 
 exists ()
 
 setStorage (ResourceStorage $storage)
 
 setIdentifier ($identifier)
 
 getCombinedIdentifier ()
 
 delete ()
 
 setDeleted ()
 
 isDeleted ()
 
 rename ($newName)
 
 copyTo (Folder $targetFolder, $targetFileName=null, $conflictMode=DuplicationBehavior::RENAME)
 
 moveTo (Folder $targetFolder, $targetFileName=null, $conflictMode=DuplicationBehavior::RENAME)
 
 getPublicUrl ($relativeToCurrentScript=false)
 
 getForLocalProcessing ($writable=true)
 
 updateProperties (array $properties)
 
 getParentFolder ()
 

Protected Member Functions

 loadMetaData ()
 
 getMetaDataRepository ()
 
 getFileIndexRepository ()
 

Protected Attributes

 $metaDataLoaded = false
 
 $metaDataProperties = []
 
 $indexingInProgress = false
 
 $updatedProperties = []
 
- Protected Attributes inherited from TYPO3\CMS\Core\Resource\AbstractFile
 $properties
 
 $storage = null
 
 $identifier
 
 $name
 
 $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 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 58 of file File.php.

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

Member Function Documentation

◆ _getMetaData()

◆ _getPropertyRaw()

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

◆ _updateMetaDataProperties()

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

◆ calculateChecksum()

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 286 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()

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

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

Parameters
string$action,canbe read, write, delete
Returns
bool

Definition at line 271 of file File.php.

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

Referenced by TYPO3\CMS\Impexp\Export\export_addSysFile(), TYPO3\CMS\Filelist\FileList\linkWrapFile(), TYPO3\CMS\Filelist\FileList\makeEdit(), and TYPO3\CMS\Core\Resource\File\toArray().

◆ getContents()

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

◆ getFileIndexRepository()

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

Definition at line 389 of file File.php.

References TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance().

◆ getMetaDataRepository()

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

◆ getProperties()

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

Returns the properties of this object.

Returns
array

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

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

◆ getPublicUrl()

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$relativeToCurrentScriptDetermines whether the URL returned should be relative to the current script, in case it is relative at all (only for the LocalDriver)
Returns
string

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 369 of file File.php.

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

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

◆ getSha1()

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

Gets SHA1 hash.

Returns
string

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 146 of file File.php.

◆ getUpdatedProperties()

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

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

Returns
array

Definition at line 257 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
Returns
bool

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 96 of file File.php.

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

◆ isIndexed()

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

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

◆ isMissing()

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

Definition at line 345 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

Returns
void

Definition at line 183 of file File.php.

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

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

◆ process()

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

Returns a modified version of the file.

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

Definition at line 302 of file File.php.

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

Referenced by TYPO3\CMS\Backend\Form\Element\ImageManipulationElement\getPreview().

◆ setContents()

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

Replace the current file contents with the given string

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

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 160 of file File.php.

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

◆ setIndexingInProgess()

TYPO3\CMS\Core\Resource\File::setIndexingInProgess (   $indexingState)
Returns
void

Definition at line 398 of file File.php.

◆ setMissing()

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

Definition at line 353 of file File.php.

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

◆ toArray()

TYPO3\CMS\Core\Resource\File::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
Returns
void

Definition at line 205 of file File.php.

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

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

Member Data Documentation

◆ $indexingInProgress

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

Definition at line 40 of file File.php.

◆ $metaDataLoaded

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

Definition at line 28 of file File.php.

◆ $metaDataProperties

TYPO3\CMS\Core\Resource\File::$metaDataProperties = []
protected

Definition at line 33 of file File.php.

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

◆ $updatedProperties

TYPO3\CMS\Core\Resource\File::$updatedProperties = []
protected

Definition at line 48 of file File.php.

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