TYPO3  7.6
Public Member Functions | Public Attributes | Protected Attributes | List of all members
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 22 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 486 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 433 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 376 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 418 of file AbstractFile.php.

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

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

getContents ( )

Get the contents of this file

Exceptions
\RuntimeException
Returns
string File contents

Implements FileInterface.

Definition at line 326 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 225 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 252 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 543 of file AbstractFile.php.

References AbstractFile\getStorage().

Referenced by Indexer\extractRequiredMetaData(), MetaDataRepository\findByFile(), and SelectImage\insertPlainImage().

getHashedIdentifier ( )

Get hashed identifier

Returns
string

Implements ResourceInterface.

Definition at line 154 of file AbstractFile.php.

getIdentifier ( )
getMimeType ( )

Get the MIME type of this file

Returns
string mime type

Implements FileInterface.

Definition at line 266 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 239 of file AbstractFile.php.

References AbstractFile\getProperty().

getName ( )

Returns the name of this file

Returns
string

Implements ResourceInterface.

Definition at line 164 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 176 of file AbstractFile.php.

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

getParentFolder ( )

Returns the parent folder.

Returns
FolderInterface

Implements ResourceInterface.

Definition at line 568 of file AbstractFile.php.

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

getProperties ( )

Returns the properties of this object.

Returns
array

Definition at line 134 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 120 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 524 of file AbstractFile.php.

References AbstractFile\getStorage().

getSha1 ( )

Returns the Sha1 of this file

Exceptions
\RuntimeException
Returns
string

Implements FileInterface.

Definition at line 211 of file AbstractFile.php.

References AbstractFile\getStorage().

getSize ( )

Returns the size of this file

Exceptions
\RuntimeException
Returns
int

Implements FileInterface.

Definition at line 187 of file AbstractFile.php.

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

Referenced by File\toArray().

getStorage ( )
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 284 of file AbstractFile.php.

References AbstractFile\getMimeType().

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

getUid ( )
hasProperty (   $key)

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

Parameters
string$key
Returns
bool

Implements FileInterface.

Definition at line 109 of file AbstractFile.php.

Referenced by AbstractFile\getProperty().

isDeleted ( )

Returns TRUE if this file has been deleted

Returns
bool

Definition at line 455 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 504 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 468 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 342 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 445 of file AbstractFile.php.

setIdentifier (   $identifier)

Set the identifier of this file

Definition at line 406 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 392 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 63 of file AbstractFile.php.

Referenced by AbstractFile\isDeleted().

$identifier
protected

Definition at line 49 of file AbstractFile.php.

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

$name
protected
$properties
protected

Definition at line 33 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 98 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 86 of file AbstractFile.php.

Referenced by Indexer\getFileType().

const FILETYPE_IMAGE = 2
const FILETYPE_TEXT = 1

Any kind of text

See Also
http://www.iana.org/assignments/media-types/text

Definition at line 74 of file AbstractFile.php.

Referenced by Indexer\getFileType().

const FILETYPE_UNKNOWN = 0

any other file

Definition at line 68 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 92 of file AbstractFile.php.

Referenced by Indexer\getFileType().