TYPO3 CMS  TYPO3_6-2
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

 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='renameNewFile')
 
 moveTo (Folder $targetFolder, $targetFileName=NULL, $conflictMode='renameNewFile')
 
 getPublicUrl ($relativeToCurrentScript=FALSE)
 
 getForLocalProcessing ($writable=TRUE)
 
 updateProperties (array $properties)
 
 getParentFolder ()
 
- Public Member Functions inherited from TYPO3\CMS\Core\Resource\FileInterface
 isIndexed ()
 
 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
 
const FILETYPE_SOFTWARE = 5
 

Protected Attributes

 $properties
 
 $storage = NULL
 
 $identifier
 
 $name
 
 $deleted = FALSE
 

Detailed Description

Abstract file representation in the file abstraction layer.

Author
Ingmar Schlecht ingma.nosp@m.r@ty.nosp@m.po3.o.nosp@m.rg

Definition at line 24 of file AbstractFile.php.

Member Function Documentation

◆ copyTo()

TYPO3\CMS\Core\Resource\AbstractFile::copyTo ( Folder  $targetFolder,
  $targetFileName = NULL,
  $conflictMode = 'renameNewFile' 
)

Copies this file into a target folder

Parameters
Folder$targetFolderFolder to copy file into.
string$targetFileNamean optional destination fileName
string$conflictModeoverrideExistingFile", "renameNewFile", "cancel
Exceptions

Definition at line 468 of file AbstractFile.php.

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

◆ delete()

TYPO3\CMS\Core\Resource\AbstractFile::delete ( )

Deletes this file from its storage. This also means that this object becomes useless.

Returns
boolean TRUE if deletion succeeded

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 419 of file AbstractFile.php.

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

◆ exists()

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
boolean TRUE if this file physically exists

Definition at line 366 of file AbstractFile.php.

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

Referenced by TYPO3\CMS\Core\Resource\ProcessedFile\needsReprocessing(), TYPO3\CMS\Core\Resource\ProcessedFile\setName(), and TYPO3\CMS\Core\Resource\ProcessedFile\updateProperties().

◆ getCombinedIdentifier()

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 405 of file AbstractFile.php.

References TYPO3\CMS\Core\Utility\MathUtility\canBeInterpretedAsInteger(), TYPO3\CMS\Core\Resource\AbstractFile\getIdentifier(), and TYPO3\CMS\Core\Resource\AbstractFile\getStorage().

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

◆ getContents()

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

Get the contents of this file

Exceptions

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 319 of file AbstractFile.php.

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

◆ getCreationTime()

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

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

◆ getExtension()

◆ getForLocalProcessing()

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
boolean$writableSet this to FALSE if you only want to do read operations on the file.
Exceptions

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 522 of file AbstractFile.php.

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

Referenced by 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\Service\IndexerService\getFactory().

◆ getHashedIdentifier()

TYPO3\CMS\Core\Resource\AbstractFile::getHashedIdentifier ( )

Get hashed identifier

Returns
string

Implements TYPO3\CMS\Core\Resource\ResourceInterface.

Definition at line 158 of file AbstractFile.php.

◆ getIdentifier()

◆ getMimeType()

◆ getModificationTime()

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

Returns the date (as UNIX timestamp) the file was last modified.

Exceptions

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 236 of file AbstractFile.php.

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

◆ getName()

◆ getNameWithoutExtension()

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

Returns the basename (the name without extension) of this file.

Returns
string

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 178 of file AbstractFile.php.

References TYPO3\CMS\Core\Resource\AbstractFile\getName(), and TYPO3\CMS\Core\Utility\PathUtility\pathinfo().

◆ getParentFolder()

TYPO3\CMS\Core\Resource\AbstractFile::getParentFolder ( )

◆ getProperties()

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

Returns the properties of this object.

Returns
array

Definition at line 140 of file AbstractFile.php.

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

◆ getProperty()

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

◆ getPublicUrl()

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

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 504 of file AbstractFile.php.

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

◆ getSha1()

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

Returns the Sha1 of this file

Exceptions

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 210 of file AbstractFile.php.

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

◆ getSize()

TYPO3\CMS\Core\Resource\AbstractFile::getSize ( )

◆ getStorage()

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 352 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\AbstractFile\delete(), TYPO3\CMS\Core\Resource\Index\MetaDataRepository\findByFile(), TYPO3\CMS\Core\Resource\Service\IndexerService\gatherFileInformation(), TYPO3\CMS\Core\Resource\AbstractFile\getCombinedIdentifier(), TYPO3\CMS\Core\Resource\File\getContents(), TYPO3\CMS\Core\Resource\AbstractFile\getContents(), TYPO3\CMS\Core\Resource\FileRepository\getFileIndexStatus(), 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\getWhereClauseForFile(), 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(), and TYPO3\CMS\Core\Resource\ProcessedFile\toArray().

◆ getType()

TYPO3\CMS\Core\Resource\AbstractFile::getType ( )

◆ getUid()

◆ hasProperty()

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

Returns true if the given property key exists for this file.

Parameters
string$key
Returns
boolean

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 117 of file AbstractFile.php.

Referenced by TYPO3\CMS\Core\Resource\AbstractFile\getProperty().

◆ isDeleted()

TYPO3\CMS\Core\Resource\AbstractFile::isDeleted ( )

Returns TRUE if this file has been deleted

Returns
boolean

Definition at line 439 of file AbstractFile.php.

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

◆ moveTo()

TYPO3\CMS\Core\Resource\AbstractFile::moveTo ( Folder  $targetFolder,
  $targetFileName = NULL,
  $conflictMode = 'renameNewFile' 
)

Moves the file into the target folder

Parameters
Folder$targetFolderFolder to move file into.
string$targetFileNamean optional destination fileName
string$conflictModeoverrideExistingFile", "renameNewFile", "cancel
Exceptions

Definition at line 485 of file AbstractFile.php.

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

◆ rename()

TYPO3\CMS\Core\Resource\AbstractFile::rename (   $newName)

Renames this file.

Parameters
string$newNameThe new file name
Exceptions

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 451 of file AbstractFile.php.

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

◆ setContents()

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

Replace the current file contents with the given string

Parameters
string$contentsThe contents to write to the file.
Exceptions

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 334 of file AbstractFile.php.

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

◆ 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.

Returns
void

Definition at line 430 of file AbstractFile.php.

◆ setIdentifier()

TYPO3\CMS\Core\Resource\AbstractFile::setIdentifier (   $identifier)

Set the identifier of this file

Definition at line 394 of file AbstractFile.php.

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

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

◆ setStorage()

TYPO3\CMS\Core\Resource\AbstractFile::setStorage ( ResourceStorage  $storage)

Sets the storage this file is located in. This is only meant for -internal usage; don't use it to move files.

Definition at line 381 of file AbstractFile.php.

References TYPO3\CMS\Core\Resource\AbstractFile\$storage, and TYPO3\CMS\Core\Resource\ResourceStorage\getUid().

◆ 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

Referenced by TYPO3\CMS\Core\Resource\AbstractFile\getForLocalProcessing().

Member Data Documentation

◆ $deleted

TYPO3\CMS\Core\Resource\AbstractFile::$deleted = FALSE
protected

Definition at line 65 of file AbstractFile.php.

Referenced by TYPO3\CMS\Core\Resource\AbstractFile\isDeleted().

◆ $identifier

TYPO3\CMS\Core\Resource\AbstractFile::$identifier
protected

◆ $name

◆ $properties

◆ $storage

TYPO3\CMS\Core\Resource\AbstractFile::$storage = NULL
protected

◆ FILETYPE_APPLICATION

const TYPO3\CMS\Core\Resource\AbstractFile::FILETYPE_APPLICATION = 5

◆ FILETYPE_AUDIO

const TYPO3\CMS\Core\Resource\AbstractFile::FILETYPE_AUDIO = 3

Any kind of audio file

See also
http://www.iana.org/assignments/media-types/audio

Definition at line 88 of file AbstractFile.php.

Referenced by TYPO3\CMS\Core\Resource\Index\Indexer\getFileType().

◆ FILETYPE_IMAGE

◆ FILETYPE_SOFTWARE

const TYPO3\CMS\Core\Resource\AbstractFile::FILETYPE_SOFTWARE = 5

Any kind of software, often known as "application"

Deprecated:
since 6.1, will be removed in 6.3. Use rather FILETYPE_APPLICATION which matches the Iana standard.

Definition at line 106 of file AbstractFile.php.

◆ FILETYPE_TEXT

const TYPO3\CMS\Core\Resource\AbstractFile::FILETYPE_TEXT = 1

◆ FILETYPE_UNKNOWN

const TYPO3\CMS\Core\Resource\AbstractFile::FILETYPE_UNKNOWN = 0

any other file

Definition at line 70 of file AbstractFile.php.

Referenced by TYPO3\CMS\Core\Resource\Index\Indexer\getFileType().

◆ FILETYPE_VIDEO

const TYPO3\CMS\Core\Resource\AbstractFile::FILETYPE_VIDEO = 4