TYPO3 CMS  TYPO3_7-6
TYPO3\CMS\Core\Resource\ProcessedFile Class Reference
Inheritance diagram for TYPO3\CMS\Core\Resource\ProcessedFile:
TYPO3\CMS\Core\Resource\AbstractFile TYPO3\CMS\Core\Resource\FileInterface TYPO3\CMS\Core\Resource\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 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 ()
 

Public Attributes

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

Protected Member Functions

 reconstituteFromDatabaseRecord (array $databaseRow)
 
 isUnchanged ()
 

Protected Attributes

 $taskType
 
 $task
 
 $taskTypeRegistry
 
 $processingConfiguration
 
 $originalFile
 
 $originalFileSha1
 
 $updated = false
 
- Protected Attributes inherited from TYPO3\CMS\Core\Resource\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 40 of file ProcessedFile.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Resource\ProcessedFile::__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 114 of file ProcessedFile.php.

References TYPO3\CMS\Core\Resource\ProcessedFile\$originalFile, TYPO3\CMS\Core\Resource\ProcessedFile\$processingConfiguration, TYPO3\CMS\Core\Resource\ProcessedFile\$taskType, TYPO3\CMS\Core\Resource\AbstractFile\getStorage(), TYPO3\CMS\Core\Utility\GeneralUtility\makeInstance(), and TYPO3\CMS\Core\Resource\ProcessedFile\reconstituteFromDatabaseRecord().

Member Function Documentation

◆ calculateChecksum()

TYPO3\CMS\Core\Resource\ProcessedFile::calculateChecksum ( )

◆ delete()

TYPO3\CMS\Core\Resource\ProcessedFile::delete (   $force = false)

Delete processed file

Parameters
bool$force
Returns
bool

Definition at line 422 of file ProcessedFile.php.

References TYPO3\CMS\Core\Resource\ProcessedFile\isUnchanged(), and TYPO3\CMS\Core\Resource\ProcessedFile\usesOriginalFile().

◆ generateProcessedFileNameWithoutExtension()

TYPO3\CMS\Core\Resource\ProcessedFile::generateProcessedFileNameWithoutExtension ( )

Generate the name of of the new File

Returns
string

Definition at line 541 of file ProcessedFile.php.

References TYPO3\CMS\Core\Resource\AbstractFile\$name, and TYPO3\CMS\Core\Resource\ProcessedFile\calculateChecksum().

◆ getIdentifier()

TYPO3\CMS\Core\Resource\ProcessedFile::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 TYPO3\CMS\Core\Resource\ResourceInterface.

Definition at line 294 of file ProcessedFile.php.

References TYPO3\CMS\Core\Resource\ProcessedFile\getOriginalFile(), and TYPO3\CMS\Core\Resource\ProcessedFile\usesOriginalFile().

Referenced by TYPO3\CMS\Core\Resource\ProcessedFile\toArray().

◆ getName()

TYPO3\CMS\Core\Resource\ProcessedFile::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 TYPO3\CMS\Core\Resource\ResourceInterface.

Definition at line 308 of file ProcessedFile.php.

References TYPO3\CMS\Core\Resource\AbstractFile\$name, and TYPO3\CMS\Core\Resource\ProcessedFile\usesOriginalFile().

Referenced by TYPO3\CMS\Core\Resource\ProcessedFile\toArray(), and TYPO3\CMS\Core\Resource\ResourceStorage\updateProcessedFile().

◆ getOriginalFile()

◆ getProcessingConfiguration()

TYPO3\CMS\Core\Resource\ProcessedFile::getProcessingConfiguration ( )

◆ getProperty()

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

Getter for file-properties

Parameters
string$key
Returns
mixed

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 441 of file ProcessedFile.php.

References TYPO3\CMS\Core\Resource\ProcessedFile\isUnchanged().

Referenced by TYPO3\CMS\Extbase\Service\ImageService\getCompatibilityImageResourceValues().

◆ getPublicUrl()

TYPO3\CMS\Core\Resource\ProcessedFile::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 TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 556 of file ProcessedFile.php.

References TYPO3\CMS\Core\Resource\ProcessedFile\getOriginalFile(), TYPO3\CMS\Core\Resource\AbstractFile\getStorage(), and TYPO3\CMS\Core\Resource\ProcessedFile\usesOriginalFile().

Referenced by TYPO3\CMS\Extbase\Service\ImageService\getCompatibilityImageResourceValues().

◆ getTask()

TYPO3\CMS\Core\Resource\ProcessedFile::getTask ( )

◆ getTaskIdentifier()

TYPO3\CMS\Core\Resource\ProcessedFile::getTaskIdentifier ( )

Getter for the task identifier.

Returns
string

Definition at line 516 of file ProcessedFile.php.

References TYPO3\CMS\Core\Resource\ProcessedFile\$taskType.

◆ getUid()

TYPO3\CMS\Core\Resource\ProcessedFile::getUid ( )

Returns the uid of this file

Returns
int

Definition at line 456 of file ProcessedFile.php.

Referenced by TYPO3\CMS\Core\Resource\ProcessedFile\toArray().

◆ isIndexed()

TYPO3\CMS\Core\Resource\ProcessedFile::isIndexed ( )

Returns TRUE if this file is indexed

Returns
bool

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 205 of file ProcessedFile.php.

◆ isNew()

TYPO3\CMS\Core\Resource\ProcessedFile::isNew ( )

Checks whether the ProcessedFile Object is newly created

Returns
bool

Definition at line 226 of file ProcessedFile.php.

References TYPO3\CMS\Core\Resource\ProcessedFile\isPersisted().

◆ isOutdated()

TYPO3\CMS\Core\Resource\ProcessedFile::isOutdated ( )

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

Returns
bool

Definition at line 411 of file ProcessedFile.php.

References TYPO3\CMS\Core\Resource\ProcessedFile\needsReprocessing().

◆ isPersisted()

TYPO3\CMS\Core\Resource\ProcessedFile::isPersisted ( )

Checks whether the ProcessedFile already has an entry in sys_file_processedfile table

Returns
bool

Definition at line 216 of file ProcessedFile.php.

Referenced by TYPO3\CMS\Core\Resource\ProcessedFile\isNew(), and TYPO3\CMS\Core\Resource\ProcessedFile\isProcessed().

◆ isProcessed()

TYPO3\CMS\Core\Resource\ProcessedFile::isProcessed ( )

Returns TRUE if this file is already processed.

Returns
bool

Definition at line 270 of file ProcessedFile.php.

References TYPO3\CMS\Core\Resource\ProcessedFile\isPersisted(), and TYPO3\CMS\Core\Resource\ProcessedFile\needsReprocessing().

◆ isUnchanged()

TYPO3\CMS\Core\Resource\ProcessedFile::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 382 of file ProcessedFile.php.

References TYPO3\CMS\Core\Resource\ProcessedFile\usesOriginalFile().

Referenced by TYPO3\CMS\Core\Resource\ProcessedFile\delete(), TYPO3\CMS\Core\Resource\ProcessedFile\getProperty(), and TYPO3\CMS\Core\Resource\ProcessedFile\updateProperties().

◆ isUpdated()

TYPO3\CMS\Core\Resource\ProcessedFile::isUpdated ( )

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

Returns
bool

Definition at line 237 of file ProcessedFile.php.

References TYPO3\CMS\Core\Resource\ProcessedFile\$updated.

◆ needsReprocessing()

◆ reconstituteFromDatabaseRecord()

TYPO3\CMS\Core\Resource\ProcessedFile::reconstituteFromDatabaseRecord ( array  $databaseRow)
protected

Creates a ProcessedFile object from a database record.

Parameters
array$databaseRow
Returns
ProcessedFile

Definition at line 133 of file ProcessedFile.php.

Referenced by TYPO3\CMS\Core\Resource\ProcessedFile\__construct().

◆ setContents()

TYPO3\CMS\Core\Resource\ProcessedFile::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

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 169 of file ProcessedFile.php.

◆ setName()

TYPO3\CMS\Core\Resource\ProcessedFile::setName (   $name)

◆ setUsesOriginalFile()

TYPO3\CMS\Core\Resource\ProcessedFile::setUsesOriginalFile ( )
Returns
void

Definition at line 390 of file ProcessedFile.php.

◆ toArray()

◆ updateProperties()

TYPO3\CMS\Core\Resource\ProcessedFile::updateProperties ( array  $properties)

◆ updateWithLocalFile()

TYPO3\CMS\Core\Resource\ProcessedFile::updateWithLocalFile (   $filePath)

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

Parameters
string$filePath
Returns
void
Exceptions

Definition at line 181 of file ProcessedFile.php.

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

Referenced by TYPO3\CMS\Core\Resource\OnlineMedia\Processing\PreviewProcessing\needsReprocessing().

◆ usesOriginalFile()

Member Data Documentation

◆ $originalFile

TYPO3\CMS\Core\Resource\ProcessedFile::$originalFile
protected

◆ $originalFileSha1

TYPO3\CMS\Core\Resource\ProcessedFile::$originalFileSha1
protected

◆ $processingConfiguration

TYPO3\CMS\Core\Resource\ProcessedFile::$processingConfiguration
protected

◆ $task

TYPO3\CMS\Core\Resource\ProcessedFile::$task
protected

Definition at line 67 of file ProcessedFile.php.

Referenced by TYPO3\CMS\Core\Resource\ProcessedFile\getTask().

◆ $taskType

TYPO3\CMS\Core\Resource\ProcessedFile::$taskType
protected

◆ $taskTypeRegistry

TYPO3\CMS\Core\Resource\ProcessedFile::$taskTypeRegistry
protected

Definition at line 72 of file ProcessedFile.php.

◆ $updated

TYPO3\CMS\Core\Resource\ProcessedFile::$updated = false
protected

Definition at line 103 of file ProcessedFile.php.

Referenced by TYPO3\CMS\Core\Resource\ProcessedFile\isUpdated().

◆ CONTEXT_IMAGECROPSCALEMASK

const TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGECROPSCALEMASK = 'Image.CropScaleMask'

◆ CONTEXT_IMAGEPREVIEW