‪TYPO3CMS  ‪main
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, string $taskType, array $processingConfiguration, array $databaseRow=null)
 
 setContents (string $contents)
 
 updateWithLocalFile (string $filePath)
 
false isIndexed ()
 
 isPersisted ()
 
 isNew ()
 
 isUpdated ()
 
 setName (string $name)
 
bool exists ()
 
 isProcessed ()
 
 getOriginalFile ()
 
non empty string getIdentifier ()
 
non empty string getName ()
 
 updateProperties (array $properties)
 
array< non-empty-string, toArray():array { if( $this->usesOriginalFile()) { $properties=$this-> originalFile getProperties ()
 
 setUsesOriginalFile ()
 
 updateProcessingUrl (string $url)
 
 usesOriginalFile ()
 
 isOutdated ()
 
 delete (bool $force=false)
 
 getProperty (string $key)
 
 getUid ()
 
 needsReprocessing ()
 
 getProcessingConfiguration ()
 
 getTaskIdentifier ()
 
 getTask ()
 
 generateProcessedFileNameWithoutExtension ()
 
non empty string null getPublicUrl ()
 
- ‪Public Member Functions inherited from ‪TYPO3\CMS\Core\Resource\AbstractFile
 hasProperty (string $key)
 
non empty string getHashedIdentifier ()
 
 getNameWithoutExtension ()
 
int< 0, getSize():int { if( $this->deleted) { throw new \RuntimeException( 'File has been deleted.', 1329821480);} if(empty( $this->properties[ 'size'])) { $fileInfo=$this-> getStorage () -> getFileInfoByIdentifier($this->getIdentifier(), ['size'])
 
non empty string getSha1 ()
 
 getCreationTime ()
 
 getModificationTime ()
 
 getExtension ()
 
non empty string getMimeType ()
 
int getType ()
 
 isType (FileType $fileType)
 
bool isImage ()
 
bool isMediaFile ()
 
bool isTextFile ()
 
 getContents ()
 
 getStorage ()
 
$this setStorage (ResourceStorage $storage)
 
$this setIdentifier ($identifier)
 
string getCombinedIdentifier ()
 
 delete ()
 
 setDeleted ()
 
bool isDeleted ()
 
 rename (string $newName, $conflictMode=DuplicationBehavior::RENAME)
 
File copyTo (Folder $targetFolder, $targetFileName=null, $conflictMode=DuplicationBehavior::RENAME)
 
File moveTo (Folder $targetFolder, $targetFileName=null, $conflictMode=DuplicationBehavior::RENAME)
 
non empty string getForLocalProcessing (bool $writable=true)
 
 getParentFolder ()
 

Public Attributes

const CONTEXT_IMAGEPREVIEW = 'Image.Preview'
 
const CONTEXT_IMAGECROPSCALEMASK = 'Image.CropScaleMask'
 
 $properties ['identifier'] = ''
 
 else
 
- ‪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
 
array< non-empty-string, function getProperties() { return $this-> properties
 
 $size = array_pop($fileInfo)
 
 else
 

Protected Member Functions

 reconstituteFromDatabaseRecord (array $databaseRow)
 
 calculateChecksum ()
 
 isUnchanged ()
 

Protected Attributes

string $taskType
 
Processing TaskInterface $task = null
 
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 null $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 46 of file ProcessedFile.php.

Constructor & Destructor Documentation

◆ __construct()

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

Member Function Documentation

◆ calculateChecksum()

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

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

Definition at line 144 of file ProcessedFile.php.

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

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

◆ delete()

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

◆ 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 249 of file ProcessedFile.php.

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

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

◆ generateProcessedFileNameWithoutExtension()

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

◆ getIdentifier()

non empty 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
‪non-empty-string

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

Definition at line 287 of file ProcessedFile.php.

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

Referenced by TYPO3\CMS\Core\Resource\Exception\FileAlreadyProcessedException\__construct().

◆ getName()

non empty 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
‪non-empty-string

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

Definition at line 301 of file ProcessedFile.php.

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

Referenced by TYPO3\CMS\Core\Resource\ResourceStorage\updateProcessedFile().

◆ getOriginalFile()

◆ getProcessingConfiguration()

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

Returns the processing information

Definition at line 487 of file ProcessedFile.php.

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

◆ getProperties()

array<non-empty-string, toArray(): array { if ($this->usesOriginalFile()) { $properties = $this-> originalFile TYPO3\CMS\Core\Resource\ProcessedFile::getProperties ( )

Basic array function for the DB update

Returns
‪array<non-empty-string, mixed>

◆ getProperty()

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

Getter for file-properties

Parameters
non-empty-string$key

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

Definition at line 429 of file ProcessedFile.php.

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

◆ getPublicUrl()

non empty string null TYPO3\CMS\Core\Resource\ProcessedFile::getPublicUrl ( )

Returns a publicly accessible URL for this file

Returns
‪non-empty-string|null NULL if file is deleted, the generated URL otherwise

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

Definition at line 529 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\AbstractFile\getStorage(), and TYPO3\CMS\Core\Resource\ProcessedFile\usesOriginalFile().

◆ getTask()

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

Returns the task object associated with this processed file.

Definition at line 503 of file ProcessedFile.php.

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

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

◆ getTaskIdentifier()

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

Getter for the task identifier.

Definition at line 495 of file ProcessedFile.php.

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

◆ getUid()

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

Returns the uid of this file

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

Definition at line 441 of file ProcessedFile.php.

References TYPO3\CMS\Core\Resource\AbstractFile\properties.

Referenced by TYPO3\CMS\Core\Resource\ProcessedFileRepository\update().

◆ isIndexed()

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

Returns TRUE if this file is indexed

Returns
‪false

Definition at line 194 of file ProcessedFile.php.

◆ isNew()

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

Checks whether the ProcessedFile Object is newly created

Definition at line 211 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.

Definition at line 404 of file ProcessedFile.php.

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

◆ isPersisted()

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

◆ isProcessed()

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

◆ isUnchanged()

TYPO3\CMS\Core\Resource\ProcessedFile::isUnchanged ( )
protected

◆ isUpdated()

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

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

Definition at line 220 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.

Definition at line 120 of file ProcessedFile.php.

References TYPO3\CMS\Core\Resource\AbstractFile\properties.

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

◆ setContents()

TYPO3\CMS\Core\Resource\ProcessedFile::setContents ( string  $contents)

Replace the current file contents with the given string

Exceptions

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

Definition at line 157 of file ProcessedFile.php.

◆ setName()

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

◆ setUsesOriginalFile()

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

Defines that the original file should be used.

Definition at line 381 of file ProcessedFile.php.

◆ updateProcessingUrl()

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

Definition at line 390 of file ProcessedFile.php.

References TYPO3\CMS\Webhooks\Message\$url.

◆ updateProperties()

◆ updateWithLocalFile()

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

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

Parameters
string$filePath
Exceptions

Definition at line 168 of file ProcessedFile.php.

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

◆ 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 79 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 86 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 98 of file ProcessedFile.php.

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

◆ $properties

TYPO3\CMS\Core\Resource\ProcessedFile::$properties[ 'configuration'] = ''

◆ $task

Processing TaskInterface TYPO3\CMS\Core\Resource\ProcessedFile::$task = null
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 66 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 69 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 92 of file ProcessedFile.php.

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

◆ CONTEXT_IMAGECROPSCALEMASK

◆ CONTEXT_IMAGEPREVIEW

const TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGEPREVIEW = 'Image.Preview'

◆ else

TYPO3\CMS\Core\Resource\ProcessedFile::else
Initial value:

Definition at line 352 of file ProcessedFile.php.

‪TYPO3\CMS\Core\Resource\ProcessedFile\$properties
‪$properties['identifier']
Definition: ProcessedFile.php:345
‪TYPO3\CMS\Core\Resource\AbstractFile\properties
‪array< non-empty-string, function getProperties() { return $this-> properties
Definition: AbstractFile.php:141