116 $this->storage = $originalFile->
getStorage()->getProcessingFolder()->getStorage();
119 if (is_array($databaseRow)) {
132 $this->taskType = $this->taskType ?: $databaseRow[
'task_type'];
133 $this->processingConfiguration = $this->processingConfiguration ?: unserialize($databaseRow[
'configuration']);
135 $this->originalFileSha1 = $databaseRow[
'originalfilesha1'];
136 $this->identifier = $databaseRow[
'identifier'];
137 $this->name = $databaseRow[
'name'];
138 $this->properties = $databaseRow;
152 return $this->
getTask()->getConfigurationChecksum();
166 throw new \BadMethodCallException(
'Setting contents not possible for processed file.', 1305438528);
177 if ($this->identifier === NULL) {
178 throw new \RuntimeException(
'Cannot update original file!', 1350582054);
180 $processingFolder = $this->originalFile->getStorage()->getProcessingFolder();
181 $addedFile = $this->storage->updateProcessedFile($filePath, $this, $processingFolder);
184 $this->identifier = $addedFile->getIdentifier();
185 $this->originalFileSha1 = $this->originalFile->getSha1();
187 $this->deleted = FALSE;
188 $this->updated = TRUE;
210 return is_array($this->properties) && array_key_exists(
'uid', $this->properties) && $this->properties[
'uid'] > 0;
239 if ($this->name !==
$name && $this->name !==
'' && $this->
exists()) {
245 $this->identifier = $this->storage->getProcessingFolder()->getIdentifier() .
$this->name;
247 $this->updated = TRUE;
296 return $this->originalFile->getName();
309 if (!is_array($this->properties)) {
310 $this->properties = array();
314 $this->properties[
'uid'] = $properties[
'uid'];
318 $this->properties = array_merge($this->properties, $properties);
322 $this->properties = array_merge($this->properties, $this->storage->getFileInfo($this));
334 $properties = $this->originalFile->getProperties();
347 $properties[
'configuration'] = serialize($this->processingConfiguration);
352 'task_type' => $this->taskType,
353 'configurationsha1' => sha1(
$properties[
'configuration']),
354 'original' => $this->originalFile->getUid(),
365 return $this->identifier == NULL || $this->identifier === $this->originalFile->getIdentifier();
373 $this->identifier = $this->originalFile->getIdentifier();
374 $this->updated = TRUE;
375 $this->originalFileSha1 = $this->originalFile->getSha1();
400 public function delete($force = FALSE) {
406 return parent::delete();
422 return $this->originalFile->getProperty($key);
424 return $this->properties[$key];
434 return $this->properties[
'uid'];
444 $fileMustBeRecreated = FALSE;
447 if ($this->originalFile->isMissing()) {
453 $fileMustBeRecreated = TRUE;
457 if (array_key_exists(
'checksum', $this->properties) && $this->
calculateChecksum() !== $this->properties[
'checksum']) {
458 $fileMustBeRecreated = TRUE;
463 $fileMustBeRecreated = TRUE;
466 if (!array_key_exists(
'uid', $this->properties)) {
467 $fileMustBeRecreated = TRUE;
471 if ($fileMustBeRecreated && $this->
exists()) {
474 return $fileMustBeRecreated;
502 if ($this->task == NULL) {
503 $this->task = $this->taskTypeRegistry->getTaskForType($this->taskType, $this, $this->processingConfiguration);
515 $name = $this->originalFile->getNameWithoutExtension();
516 $name .=
'_' . $this->originalFile->getUid();
529 if ($this->deleted) {
532 return $this->
getOriginalFile()->getPublicUrl($relativeToCurrentScript);
534 return $this->
getStorage()->getPublicUrl($this, $relativeToCurrentScript);
updateWithLocalFile($filePath)
__construct(File $originalFile, $taskType, array $processingConfiguration, array $databaseRow=NULL)
static canBeInterpretedAsInteger($var)
reconstituteFromDatabaseRecord(array $databaseRow)
const CONTEXT_IMAGECROPSCALEMASK
static makeInstance($className)
updateProperties(array $properties)
getPublicUrl($relativeToCurrentScript=FALSE)
getProcessingConfiguration()
const CONTEXT_IMAGEPREVIEW
generateProcessedFileNameWithoutExtension()