TYPO3  7.6
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
ProcessedFile Class Reference
Inheritance diagram for ProcessedFile:
AbstractFile FileInterface ResourceInterface

Public Member Functions

 __construct (File $originalFile, $taskType, array $processingConfiguration, array $databaseRow=null)
 
 calculateChecksum ()
 
 setContents ($contents)
 
 updateWithLocalFile ($filePath)
 
 isIndexed ()
 
 isPersisted ()
 
 isNew ()
 
 isUpdated ()
 
 setName ($name)
 
 isProcessed ()
 
 getOriginalFile ()
 
 getIdentifier ()
 
 getName ()
 
 updateProperties (array $properties)
 
 toArray ()
 
 setUsesOriginalFile ()
 
 usesOriginalFile ()
 
 isOutdated ()
 
 delete ($force=false)
 
 getProperty ($key)
 
 getUid ()
 
 needsReprocessing ()
 
 getProcessingConfiguration ()
 
 getTaskIdentifier ()
 
 getTask ()
 
 generateProcessedFileNameWithoutExtension ()
 
 getPublicUrl ($relativeToCurrentScript=false)
 
- Public Member Functions inherited from 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 ()
 

Public Attributes

const CONTEXT_IMAGEPREVIEW = 'Image.Preview'
 
const CONTEXT_IMAGECROPSCALEMASK = 'Image.CropScaleMask'
 
- Public Attributes inherited from 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
 

Protected Member Functions

 reconstituteFromDatabaseRecord (array $databaseRow)
 
 isUnchanged ()
 

Protected Attributes

 $taskType
 
 $task
 
 $taskTypeRegistry
 
 $processingConfiguration
 
 $originalFile
 
 $originalFileSha1
 
 $updated = false
 
- Protected Attributes inherited from AbstractFile
 $properties
 
 $storage = null
 
 $identifier
 
 $name
 
 $deleted = false
 

Detailed Description

Representation of a specific processed version of a file. These are created by the FileProcessingService, which in turn uses helper classes for doing the actual file processing. See there for a detailed description.

Objects of this class may be freshly created during runtime or being fetched from the database. The latter indicates that the file has been processed earlier and was then cached.

Each processed file—besides belonging to one file—has been created for a certain task (context) and configuration. All these won't change during the lifetime of a processed file; the only thing that can change is the original file, or rather it's contents. In that case, the processed file has to be processed again. Detecting this is done via comparing the current SHA1 hash of the original file against the one it had at the time the file was processed. The configuration of a processed file indicates what should be done to the original file to create the processed version. This may include things like cropping, scaling, rotating, flipping or using some special magic. A file may also meet the expectations set in the configuration without any processing. In that case, the ProcessedFile object still exists, but there is no physical file directly linked to it. Instead, it then redirects most method calls to the original file object. The data of these objects are also stored in the database, to indicate that no processing is required. With such files, the identifier and name fields in the database are empty to show this.

Definition at line 38 of file ProcessedFile.php.

Constructor & Destructor Documentation

__construct ( File  $originalFile,
  $taskType,
array  $processingConfiguration,
array  $databaseRow = null 
)

Constructor for a processed file object. Should normally not be used directly, use the corresponding factory methods instead.

Parameters
File$originalFile
string$taskType
array$processingConfiguration
array$databaseRow

Definition at line 112 of file ProcessedFile.php.

References ProcessedFile\$originalFile, ProcessedFile\$processingConfiguration, ProcessedFile\$taskType, AbstractFile\getStorage(), and ProcessedFile\reconstituteFromDatabaseRecord().

Member Function Documentation

calculateChecksum ( )

Returns a unique checksum for this file's processing configuration and original file.

Returns
string

Definition at line 152 of file ProcessedFile.php.

References ProcessedFile\getTask().

Referenced by ProcessedFile\generateProcessedFileNameWithoutExtension(), ImageService\getCompatibilityImageResourceValues(), ProcessedFile\needsReprocessing(), and ProcessedFile\toArray().

delete (   $force = false)

Delete processed file

Parameters
bool$force
Returns
bool

Definition at line 420 of file ProcessedFile.php.

References ProcessedFile\isUnchanged(), and ProcessedFile\usesOriginalFile().

generateProcessedFileNameWithoutExtension ( )

Generate the name of of the new File

Returns
string

Definition at line 541 of file ProcessedFile.php.

References AbstractFile\$name, and ProcessedFile\calculateChecksum().

getIdentifier ( )

Get the identifier of the file

If there is no processed file in the file system (as the original file did not have to be modified e.g. when the original image is in the boundaries of the maxW/maxH stuff), then just return the identifier of the original file

Returns
string

Implements ResourceInterface.

Definition at line 292 of file ProcessedFile.php.

References ProcessedFile\getOriginalFile(), and ProcessedFile\usesOriginalFile().

Referenced by ProcessedFile\toArray().

getName ( )

Get the name of the file

If there is no processed file in the file system (as the original file did not have to be modified e.g. when the original image is in the boundaries of the maxW/maxH stuff) then just return the name of the original file

Returns
string

Implements ResourceInterface.

Definition at line 306 of file ProcessedFile.php.

References AbstractFile\$name, and ProcessedFile\usesOriginalFile().

Referenced by ProcessedFile\toArray(), and ResourceStorage\updateProcessedFile().

getOriginalFile ( )
getProcessingConfiguration ( )

Returns the processing information

Returns
array

Definition at line 506 of file ProcessedFile.php.

References ProcessedFile\$processingConfiguration.

getProperty (   $key)

Getter for file-properties

Parameters
string$key
Returns
mixed

Implements FileInterface.

Definition at line 440 of file ProcessedFile.php.

References ProcessedFile\isUnchanged().

Referenced by ImageService\getCompatibilityImageResourceValues().

getPublicUrl (   $relativeToCurrentScript = false)

Returns a publicly accessible URL for this file

Parameters
bool$relativeToCurrentScriptDetermines whether the URL returned should be relative to the current script, in case it is relative at all
Returns
NULL|string NULL if file is deleted, the generated URL otherwise

Implements FileInterface.

Definition at line 556 of file ProcessedFile.php.

References elseif, ProcessedFile\getOriginalFile(), AbstractFile\getStorage(), and ProcessedFile\usesOriginalFile().

Referenced by ImageService\getCompatibilityImageResourceValues().

getTask ( )

Returns the task object associated with this processed file.

Returns
Processing
Exceptions
\RuntimeException

Definition at line 527 of file ProcessedFile.php.

References ProcessedFile\$task.

Referenced by ProcessedFile\calculateChecksum(), and PreviewProcessing\getTargetFileName().

getTaskIdentifier ( )

Getter for the task identifier.

Returns
string

Definition at line 516 of file ProcessedFile.php.

References ProcessedFile\$taskType.

getUid ( )

Returns the uid of this file

Returns
int

Definition at line 455 of file ProcessedFile.php.

Referenced by ProcessedFile\toArray().

isIndexed ( )

Returns TRUE if this file is indexed

Returns
bool

Implements FileInterface.

Definition at line 203 of file ProcessedFile.php.

isNew ( )

Checks whether the ProcessedFile Object is newly created

Returns
bool

Definition at line 224 of file ProcessedFile.php.

References ProcessedFile\isPersisted().

isOutdated ( )

Returns TRUE if the original file of this file changed and the file should be processed again.

Returns
bool

Definition at line 409 of file ProcessedFile.php.

References ProcessedFile\needsReprocessing().

isPersisted ( )

Checks whether the ProcessedFile already has an entry in sys_file_processedfile table

Returns
bool

Definition at line 214 of file ProcessedFile.php.

Referenced by ProcessedFile\isNew(), and ProcessedFile\isProcessed().

isProcessed ( )

Returns TRUE if this file is already processed.

Returns
bool

Definition at line 268 of file ProcessedFile.php.

References ProcessedFile\isPersisted(), and ProcessedFile\needsReprocessing().

isUnchanged ( )
protected

Returns TRUE if this file has not been changed during processing (i.e., we just deliver the original file)

Returns
bool

Definition at line 380 of file ProcessedFile.php.

References ProcessedFile\usesOriginalFile().

Referenced by ProcessedFile\delete(), ProcessedFile\getProperty(), and ProcessedFile\updateProperties().

isUpdated ( )

Checks whether the object since last reconstitution, and therefore needs persistence again

Returns
bool

Definition at line 235 of file ProcessedFile.php.

References ProcessedFile\$updated.

needsReprocessing ( )
reconstituteFromDatabaseRecord ( array  $databaseRow)
protected

Creates a ProcessedFile object from a database record.

Parameters
array$databaseRow
Returns
ProcessedFile

Definition at line 131 of file ProcessedFile.php.

Referenced by ProcessedFile\__construct().

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).
Exceptions
\BadMethodCallException

Implements FileInterface.

Definition at line 167 of file ProcessedFile.php.

setName (   $name)

Sets a new file name

Parameters
string$name

Definition at line 245 of file ProcessedFile.php.

References AbstractFile\$name, and AbstractFile\exists().

setUsesOriginalFile ( )
Returns
void

Definition at line 388 of file ProcessedFile.php.

toArray ( )
updateProperties ( array  $properties)

Updates properties of this object. Do not use this to reconstitute an object from the database; use reconstituteFromDatabaseRecord() instead!

Parameters
array$properties

Definition at line 321 of file ProcessedFile.php.

References MathUtility\canBeInterpretedAsInteger(), AbstractFile\exists(), and ProcessedFile\isUnchanged().

Referenced by ProcessedFile\updateWithLocalFile().

updateWithLocalFile (   $filePath)

Injects a local file, which is a processing result into the object.

Parameters
string$filePath
Returns
void
Exceptions
\RuntimeException

Definition at line 179 of file ProcessedFile.php.

References ProcessedFile\updateProperties().

usesOriginalFile ( )

Member Data Documentation

$originalFile
protected

Definition at line 84 of file ProcessedFile.php.

Referenced by ProcessedFile\__construct(), and ProcessedFile\getOriginalFile().

$originalFileSha1
protected

Definition at line 93 of file ProcessedFile.php.

Referenced by ProcessedFile\needsReprocessing(), and ProcessedFile\toArray().

$processingConfiguration
protected
$task
protected

Definition at line 65 of file ProcessedFile.php.

Referenced by ProcessedFile\getTask().

$taskType
protected

Definition at line 60 of file ProcessedFile.php.

Referenced by ProcessedFile\__construct(), and ProcessedFile\getTaskIdentifier().

$taskTypeRegistry
protected

Definition at line 70 of file ProcessedFile.php.

$updated = false
protected

Definition at line 101 of file ProcessedFile.php.

Referenced by ProcessedFile\isUpdated().

const CONTEXT_IMAGECROPSCALEMASK = 'Image.CropScaleMask'

Standard processing context for the frontend, that was previously in ::getImgResource which only takes cropping, masking and scaling into account

Definition at line 53 of file ProcessedFile.php.

Referenced by ImageService\applyProcessingInstructions(), MagicImageService\createMagicImage(), DefaultAvatarProvider\getImage(), ImageManipulationElement\getPreview(), and InlineRecordContainer\renderForeignRecordHeader().

const CONTEXT_IMAGEPREVIEW = 'Image.Preview'

Basic processing context to get a processed image with smaller width/height to render a preview

Definition at line 47 of file ProcessedFile.php.

Referenced by FileInfoHook\renderFileInformationContent(), and FileBrowser\renderFilesInFolder().