‪TYPO3CMS  10.4
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)
 
string calculateChecksum ()
 
 setContents ($contents)
 
 updateWithLocalFile ($filePath)
 
bool isIndexed ()
 
bool isPersisted ()
 
bool isNew ()
 
bool isUpdated ()
 
 setName ($name)
 
bool exists ()
 
bool isProcessed ()
 
File getOriginalFile ()
 
string getIdentifier ()
 
string getName ()
 
 updateProperties (array $properties)
 
array toArray ()
 
 setUsesOriginalFile ()
 
 updateProcessingUrl (string $url)
 
bool usesOriginalFile ()
 
bool isOutdated ()
 
bool delete ($force=false)
 
mixed getProperty ($key)
 
int getUid ()
 
bool needsReprocessing ()
 
array getProcessingConfiguration ()
 
string getTaskIdentifier ()
 
Processing TaskInterface getTask ()
 
string generateProcessedFileNameWithoutExtension ()
 
string null getPublicUrl ($relativeToCurrentScript=false)
 
- ‪Public Member Functions inherited from ‪TYPO3\CMS\Core\Resource\AbstractFile
bool hasProperty ($key)
 
array getProperties ()
 
string getHashedIdentifier ()
 
string getNameWithoutExtension ()
 
int null getSize ()
 
string getSha1 ()
 
int getCreationTime ()
 
int getModificationTime ()
 
string getExtension ()
 
string getMimeType ()
 
int getType ()
 
bool isImage ()
 
bool isMediaFile ()
 
bool isTextFile ()
 
string getContents ()
 
ResourceStorage getStorage ()
 
File setStorage (ResourceStorage $storage)
 
File setIdentifier ($identifier)
 
string getCombinedIdentifier ()
 
bool delete ()
 
 setDeleted ()
 
bool isDeleted ()
 
FileInterface rename ($newName, $conflictMode=DuplicationBehavior::RENAME)
 
File copyTo (Folder $targetFolder, $targetFileName=null, $conflictMode=DuplicationBehavior::RENAME)
 
File moveTo (Folder $targetFolder, $targetFileName=null, $conflictMode=DuplicationBehavior::RENAME)
 
string getForLocalProcessing ($writable=true)
 
FolderInterface 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)
 
bool isUnchanged ()
 

Protected Attributes

string $taskType
 
Processing TaskInterface $task
 
Processing TaskTypeRegistry $taskTypeRegistry
 
array $processingConfiguration
 
File $originalFile
 
string $originalFileSha1
 
bool $updated = false
 
string $processingUrl = ''
 
- ‪Protected Attributes inherited from ‪TYPO3\CMS\Core\Resource\AbstractFile
array $properties
 
ResourceStorage $storage
 
string $identifier
 
string $name
 
bool $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 43 of file ProcessedFile.php.

Constructor & Destructor Documentation

◆ __construct()

TYPO3\CMS\Core\Resource\ProcessedFile::__construct ( File  $originalFile,
  $taskType,
array  $processingConfiguration,
array  $databaseRow = null 
)

Member Function Documentation

◆ calculateChecksum()

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

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

Returns
‪string

Definition at line 161 of file ProcessedFile.php.

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

Referenced by TYPO3\CMS\Core\Resource\ProcessedFile\generateProcessedFileNameWithoutExtension(), TYPO3\CMS\Core\Resource\ProcessedFile\needsReprocessing(), and TYPO3\CMS\Core\Resource\ProcessedFile\toArray().

◆ delete()

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

Delete processed file

Parameters
bool$force
Returns
‪bool

Definition at line 458 of file ProcessedFile.php.

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

◆ exists()

bool TYPO3\CMS\Core\Resource\ProcessedFile::exists ( )

Checks if this file exists. Since the original file may reside in a different storage we ask the original file if it exists in case the processed is representing it

Returns
‪bool TRUE if this file physically exists

Reimplemented from TYPO3\CMS\Core\Resource\AbstractFile.

Definition at line 275 of file ProcessedFile.php.

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

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

◆ generateProcessedFileNameWithoutExtension()

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

◆ getIdentifier()

string 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

Reimplemented from TYPO3\CMS\Core\Resource\AbstractFile.

Definition at line 317 of file ProcessedFile.php.

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

Referenced by TYPO3\CMS\Core\Resource\Exception\FileAlreadyProcessedException\__construct(), and TYPO3\CMS\Core\Resource\ProcessedFile\toArray().

◆ getName()

string 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

Reimplemented from TYPO3\CMS\Core\Resource\AbstractFile.

Definition at line 331 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()

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

◆ getProperty()

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

Getter for file-properties

Parameters
string$key
Returns
‪mixed

Reimplemented from TYPO3\CMS\Core\Resource\AbstractFile.

Definition at line 477 of file ProcessedFile.php.

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

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

◆ getPublicUrl()

string null TYPO3\CMS\Core\Resource\ProcessedFile::getPublicUrl (   $relativeToCurrentScript = false)

Returns a publicly accessible URL for this file

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

Reimplemented from TYPO3\CMS\Core\Resource\AbstractFile.

Definition at line 591 of file ProcessedFile.php.

References TYPO3\CMS\Core\Resource\ProcessedFile\$processingUrl, TYPO3\CMS\Core\Resource\ProcessedFile\getOriginalFile(), TYPO3\CMS\Core\Resource\File\getPublicUrl(), TYPO3\CMS\Core\Resource\ResourceStorage\getPublicUrl(), TYPO3\CMS\Core\Resource\AbstractFile\getStorage(), and TYPO3\CMS\Core\Resource\ProcessedFile\usesOriginalFile().

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

◆ getTask()

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

Returns the task object associated with this processed file.

Returns
Processing\TaskInterface
Exceptions

Definition at line 562 of file ProcessedFile.php.

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

Referenced by TYPO3\CMS\Core\Resource\ProcessedFile\calculateChecksum(), and TYPO3\CMS\Core\Resource\Service\FileProcessingService\process().

◆ getTaskIdentifier()

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

Getter for the task identifier.

Returns
‪string

Definition at line 551 of file ProcessedFile.php.

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

Referenced by TYPO3\CMS\Core\Imaging\ImageDimension\getConfigurationForImageCropScaleMask().

◆ getUid()

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

Returns the uid of this file

Returns
‪int

Reimplemented from TYPO3\CMS\Core\Resource\AbstractFile.

Definition at line 491 of file ProcessedFile.php.

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

◆ isIndexed()

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

Returns TRUE if this file is indexed

Returns
‪bool

Implements TYPO3\CMS\Core\Resource\FileInterface.

Definition at line 212 of file ProcessedFile.php.

◆ isNew()

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

Checks whether the ProcessedFile Object is newly created

Returns
‪bool

Definition at line 233 of file ProcessedFile.php.

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

Referenced by TYPO3\CMS\Core\Resource\Service\FileProcessingService\process().

◆ isOutdated()

bool 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 447 of file ProcessedFile.php.

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

Referenced by TYPO3\CMS\Core\Resource\Service\FileProcessingService\process().

◆ isPersisted()

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

Checks whether the ProcessedFile already has an entry in sys_file_processedfile table

Returns
‪bool

Definition at line 223 of file ProcessedFile.php.

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

◆ isProcessed()

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

◆ isUnchanged()

bool 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 411 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()

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

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

Returns
‪bool

Definition at line 244 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

Definition at line 135 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$contents‪The contents to write to the file.
Exceptions

Reimplemented from TYPO3\CMS\Core\Resource\AbstractFile.

Definition at line 175 of file ProcessedFile.php.

◆ setName()

◆ setUsesOriginalFile()

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

◆ toArray()

◆ updateProcessingUrl()

TYPO3\CMS\Core\Resource\ProcessedFile::updateProcessingUrl ( string  $url)

Definition at line 428 of file ProcessedFile.php.

◆ updateProperties()

◆ updateWithLocalFile()

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

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

Parameters
string$filePath
Exceptions

Definition at line 186 of file ProcessedFile.php.

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

Referenced by TYPO3\CMS\Core\Resource\Processing\LocalImageProcessor\processTaskWithLocalFile().

◆ usesOriginalFile()

Member Data Documentation

◆ $originalFile

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

Reference to the original file this processed file has been created from.

Definition at line 84 of file ProcessedFile.php.

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

◆ $originalFileSha1

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

The SHA1 hash of the original file this processed version has been created for. Is used for detecting changes if the original file has been changed and thus we have to recreate this processed file.

Definition at line 92 of file ProcessedFile.php.

◆ $processingConfiguration

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

◆ $processingUrl

string TYPO3\CMS\Core\Resource\ProcessedFile::$processingUrl = ''
protected

If this is set, this URL is used as public URL This MUST be a fully qualified URL including host

Definition at line 106 of file ProcessedFile.php.

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

◆ $task

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

Definition at line 68 of file ProcessedFile.php.

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

◆ $taskType

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

Processing context, i.e. the type of processing done

Definition at line 64 of file ProcessedFile.php.

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

◆ $taskTypeRegistry

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

Definition at line 72 of file ProcessedFile.php.

◆ $updated

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

A flag that shows if this object has been updated during its lifetime, i.e. the file has been replaced with a new one.

Definition at line 99 of file ProcessedFile.php.

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

◆ CONTEXT_IMAGECROPSCALEMASK

◆ CONTEXT_IMAGEPREVIEW