‪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, $taskType, array $processingConfiguration, array $databaseRow=null)
 
string calculateChecksum ()
 
 setContents (string $contents)
 
 updateWithLocalFile ($filePath)
 
false isIndexed ()
 
bool isPersisted ()
 
bool isNew ()
 
bool isUpdated ()
 
 setName ($name)
 
bool exists ()
 
bool isProcessed ()
 
File 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)
 
bool usesOriginalFile ()
 
bool isOutdated ()
 
 delete (bool $force=false)
 
 getProperty (string $key)
 
int getUid ()
 
bool needsReprocessing ()
 
array getProcessingConfiguration ()
 
string getTaskIdentifier ()
 
 getTask ()
 
string 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 ()
 
bool isImage ()
 
bool isMediaFile ()
 
bool isTextFile ()
 
 getContents ()
 
 getStorage ()
 
$this setStorage (ResourceStorage $storage)
 
$this setIdentifier ($identifier)
 
string getCombinedIdentifier ()
 
 delete ()
 
 setDeleted ()
 
bool isDeleted ()
 
 rename (string $newName, string $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)
 
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 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,
  $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 160 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 273 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()

string 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 315 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().

◆ 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 329 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()

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

◆ 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)

◆ getPublicUrl()

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

◆ getTask()

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

Returns the task object associated with this processed file.

Exceptions

Definition at line 552 of file ProcessedFile.php.

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

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

◆ getTaskIdentifier()

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

Getter for the task identifier.

Returns
‪string

Definition at line 542 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 482 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 210 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 231 of file ProcessedFile.php.

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

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

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

◆ isPersisted()

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

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

References TYPO3\CMS\Core\Resource\AbstractFile\properties, and 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 242 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 133 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 173 of file ProcessedFile.php.

◆ setName()

◆ setUsesOriginalFile()

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

◆ updateProcessingUrl()

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

Definition at line 424 of file ProcessedFile.php.

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

◆ 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 184 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 87 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 95 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 109 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
protected

Definition at line 71 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 67 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 75 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 102 of file ProcessedFile.php.

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

◆ CONTEXT_IMAGECROPSCALEMASK

◆ CONTEXT_IMAGEPREVIEW

◆ else

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

Definition at line 384 of file ProcessedFile.php.

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