TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
AbstractFile Class Reference
Inheritance diagram for AbstractFile:
FileInterface ResourceInterface File 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=DuplicationBehavior::RENAME)
 
 moveTo (Folder $targetFolder, $targetFileName=null, $conflictMode=DuplicationBehavior::RENAME)
 
 getPublicUrl ($relativeToCurrentScript=false)
 
 getForLocalProcessing ($writable=true)
 
 updateProperties (array $properties)
 
 getParentFolder ()
 
- Public Member Functions inherited from 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
 

Protected Attributes

 $properties
 
 $storage = null
 
 $identifier
 
 $name
 
 $deleted = false
 

Detailed Description

Abstract file representation in the file abstraction layer.

Definition at line 23 of file AbstractFile.php.

Member Function Documentation

copyTo ( Folder  $targetFolder,
  $targetFileName = null,
  $conflictMode = DuplicationBehavior::RENAME 
)

Copies this file into a target folder

Parameters
Folder$targetFolderFolder to copy file into.
string$targetFileNamean optional destination fileName
string$conflictModea value of the enumeration
Exceptions
RuntimeException
Returns
File The new (copied) file.

Definition at line 492 of file AbstractFile.php.

References Folder\getStorage().

delete ( )

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

Returns
bool TRUE if deletion succeeded

Implements FileInterface.

Definition at line 439 of file AbstractFile.php.

References AbstractFile\getStorage().

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

Definition at line 382 of file AbstractFile.php.

References AbstractFile\getIdentifier().

Referenced by ProcessedFile\needsReprocessing(), ProcessedFile\setName(), and ProcessedFile\updateProperties().

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

References MathUtility\canBeInterpretedAsInteger(), AbstractFile\getIdentifier(), and AbstractFile\getStorage().

Referenced by File\calculateChecksum(), Export\export_addSysFile(), and File\toArray().

getContents ( )

Get the contents of this file

Exceptions
RuntimeException
Returns
string File contents

Implements FileInterface.

Definition at line 332 of file AbstractFile.php.

References AbstractFile\getStorage().

getCreationTime ( )

Returns the creation time of the file as Unix timestamp

Exceptions
RuntimeException
Returns
int

Implements FileInterface.

Definition at line 231 of file AbstractFile.php.

References AbstractFile\getProperty().

getExtension ( )

Get the extension of this file in a lower-case variant

Returns
string The file extension

Implements FileInterface.

Definition at line 258 of file AbstractFile.php.

References AbstractFile\getName(), and PathUtility\pathinfo().

Referenced by ImageService\getCompatibilityImageResourceValues(), OnlineMediaHelperRegistry\getOnlineMediaHelper(), and File\toArray().

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

Implements FileInterface.

Definition at line 549 of file AbstractFile.php.

References AbstractFile\getStorage().

Referenced by Export\export_addSysFile(), Indexer\extractRequiredMetaData(), and MetaDataRepository\findByFile().

getHashedIdentifier ( )

Get hashed identifier

Returns
string

Implements ResourceInterface.

Definition at line 155 of file AbstractFile.php.

getMimeType ( )

Get the MIME type of this file

Returns
string mime type

Implements FileInterface.

Definition at line 272 of file AbstractFile.php.

References AbstractFile\getIdentifier(), and AbstractFile\getStorage().

Referenced by File\calculateChecksum(), AbstractFile\getType(), and File\toArray().

getModificationTime ( )

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

Exceptions
RuntimeException
Returns
int

Implements FileInterface.

Definition at line 245 of file AbstractFile.php.

References AbstractFile\getProperty().

getName ( )

Returns the name of this file

Returns
string

Implements ResourceInterface.

Definition at line 165 of file AbstractFile.php.

References AbstractFile\$name.

Referenced by AbstractFile\getExtension(), AbstractFile\getNameWithoutExtension(), and File\toArray().

getNameWithoutExtension ( )

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

Returns
string

Implements FileInterface.

Definition at line 177 of file AbstractFile.php.

References AbstractFile\getName(), and PathUtility\pathinfo().

getParentFolder ( )

Returns the parent folder.

Returns
FolderInterface

Implements ResourceInterface.

Definition at line 574 of file AbstractFile.php.

References AbstractFile\getIdentifier(), and AbstractFile\getStorage().

getProperties ( )

Returns the properties of this object.

Returns
array

Definition at line 135 of file AbstractFile.php.

References AbstractFile\$properties.

getProperty (   $key)

Returns a property value

Parameters
string$key
Returns
mixed Property value

Implements FileInterface.

Definition at line 121 of file AbstractFile.php.

References AbstractFile\hasProperty().

Referenced by AbstractFile\getCreationTime(), AbstractFile\getModificationTime(), and AbstractFile\getUid().

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

Definition at line 530 of file AbstractFile.php.

References AbstractFile\getStorage().

getSha1 ( )

Returns the Sha1 of this file

Exceptions
RuntimeException
Returns
string

Implements FileInterface.

Definition at line 217 of file AbstractFile.php.

References AbstractFile\getStorage().

getSize ( )

Returns the size of this file

Exceptions
RuntimeException
Returns
int|null Returns null if size is not available for the file

Implements FileInterface.

Definition at line 188 of file AbstractFile.php.

References AbstractFile\getIdentifier(), and AbstractFile\getStorage().

Referenced by File\toArray().

getType ( )

Returns the fileType of this file basically there are only five main "file types" "audio" "image" "software" "text" "video" "other" see the constants in this class

Returns
int $fileType

Definition at line 290 of file AbstractFile.php.

References AbstractFile\getMimeType().

Referenced by Indexer\extractRequiredMetaData(), MetaDataRepository\findByFile(), Indexer\isFileTypeSupportedByExtractor(), File\toArray(), and File\updateProperties().

hasProperty (   $key)

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

Parameters
string$key
Returns
bool

Implements FileInterface.

Definition at line 110 of file AbstractFile.php.

Referenced by AbstractFile\getProperty().

isDeleted ( )

Returns TRUE if this file has been deleted

Returns
bool

Definition at line 461 of file AbstractFile.php.

References AbstractFile\$deleted.

moveTo ( Folder  $targetFolder,
  $targetFileName = null,
  $conflictMode = DuplicationBehavior::RENAME 
)

Moves the file into the target folder

Parameters
Folder$targetFolderFolder to move file into.
string$targetFileNamean optional destination fileName
string$conflictModea value of the enumeration
Exceptions
RuntimeException
Returns
File This file object, with updated properties.

Definition at line 510 of file AbstractFile.php.

References Folder\getStorage().

rename (   $newName)

Renames this file.

Parameters
string$newNameThe new file name
Exceptions
RuntimeException
Returns
File

Implements FileInterface.

Definition at line 474 of file AbstractFile.php.

References AbstractFile\getStorage().

setContents (   $contents)

Replace the current file contents with the given string

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

Implements FileInterface.

Definition at line 348 of file AbstractFile.php.

References AbstractFile\getStorage().

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

setIdentifier (   $identifier)

Set the identifier of this file

Definition at line 412 of file AbstractFile.php.

References AbstractFile\$identifier.

Referenced by ResourceStorage\updateProcessedFile().

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

References AbstractFile\$storage, and ResourceStorage\getUid().

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

Member Data Documentation

$deleted = false
protected

Definition at line 64 of file AbstractFile.php.

Referenced by AbstractFile\isDeleted().

$identifier
protected

Definition at line 50 of file AbstractFile.php.

Referenced by AbstractFile\getIdentifier(), and AbstractFile\setIdentifier().

$properties
protected

Definition at line 34 of file AbstractFile.php.

Referenced by AbstractFile\getProperties(), and ProcessedFile\toArray().

$storage = null
protected
const FILETYPE_APPLICATION = 5

Any kind of application

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

Definition at line 99 of file AbstractFile.php.

Referenced by Indexer\getFileType().

const FILETYPE_AUDIO = 3

Any kind of audio file

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

Definition at line 87 of file AbstractFile.php.

Referenced by Indexer\getFileType().

const FILETYPE_UNKNOWN = 0

any other file

Definition at line 69 of file AbstractFile.php.

Referenced by Indexer\getFileType().

const FILETYPE_VIDEO = 4

Any kind of video

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

Definition at line 93 of file AbstractFile.php.

Referenced by Indexer\getFileType().