‪TYPO3CMS  10.4
AbstractTask.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
22 
30 abstract class ‪AbstractTask implements ‪TaskInterface
31 {
35  protected ‪$checksumData = [];
36 
40  protected ‪$targetFile;
41 
45  protected ‪$sourceFile;
46 
50  protected ‪$configuration;
51 
55  protected ‪$type;
56 
60  protected ‪$name;
61 
65  protected ‪$executed = false;
66 
70  protected ‪$successful;
71 
77  {
78  $this->targetFile = ‪$targetFile;
79  $this->sourceFile = ‪$targetFile->‪getOriginalFile();
80  $this->configuration = ‪$configuration;
81  }
82 
90  protected function ‪getChecksumData()
91  {
92  return [
93  $this->‪getSourceFile()->‪getUid(),
94  $this->‪getType() . '.' . $this->‪getName() . $this->‪getSourceFile()->‪getModificationTime(),
95  serialize($this->configuration)
96  ];
97  }
98 
104  public function ‪getConfigurationChecksum()
105  {
106  return GeneralUtility::shortMD5(implode('|', $this->‪getChecksumData()));
107  }
108 
114  public function ‪getTargetFilename()
115  {
116  return $this->targetFile->getNameWithoutExtension()
117  . '_' . $this->‪getConfigurationChecksum()
118  . '.' . $this->‪getTargetFileExtension();
119  }
120 
127  public function ‪getTargetFileExtension()
128  {
129  return $this->targetFile->getExtension();
130  }
131 
137  public function ‪getName()
138  {
140  }
141 
147  public function ‪getType()
148  {
149  return ‪$this->type;
150  }
151 
155  public function ‪getTargetFile()
156  {
157  return ‪$this->targetFile;
158  }
159 
164  {
165  $this->targetFile = ‪$targetFile;
166  }
167 
171  public function ‪getSourceFile()
172  {
173  return ‪$this->sourceFile;
174  }
175 
180  {
181  $this->sourceFile = ‪$sourceFile;
182  }
183 
187  public function ‪getConfiguration()
188  {
190  }
191 
199  abstract protected function ‪isValidConfiguration(array ‪$configuration);
200 
206  public function ‪isExecuted()
207  {
208  return ‪$this->executed;
209  }
210 
217  public function ‪setExecuted(‪$successful)
218  {
219  $this->executed = true;
220  $this->successful = ‪$successful;
221  }
222 
229  public function ‪isSuccessful()
230  {
231  if (!$this->executed) {
232  throw new \LogicException('Task has not been executed; cannot determine success.', 1352549235);
233  }
234 
235  return ‪$this->successful;
236  }
237 }
‪TYPO3\CMS\Core\Resource\ProcessedFile\getOriginalFile
‪File getOriginalFile()
Definition: ProcessedFile.php:303
‪TYPO3\CMS\Core\Resource\Processing\AbstractTask\getName
‪string getName()
Definition: AbstractTask.php:129
‪TYPO3\CMS\Core\Resource\Processing\AbstractTask\$targetFile
‪Resource ProcessedFile $targetFile
Definition: AbstractTask.php:38
‪TYPO3\CMS\Core\Resource\Processing\AbstractTask\$checksumData
‪array $checksumData
Definition: AbstractTask.php:34
‪TYPO3\CMS\Core\Resource\Processing\TaskInterface
Definition: TaskInterface.php:33
‪TYPO3\CMS\Core\Resource\Processing\AbstractTask\getTargetFileExtension
‪string getTargetFileExtension()
Definition: AbstractTask.php:119
‪TYPO3\CMS\Core\Resource\AbstractFile\getModificationTime
‪int getModificationTime()
Definition: AbstractFile.php:241
‪TYPO3\CMS\Core\Resource\Processing\AbstractTask\setExecuted
‪setExecuted($successful)
Definition: AbstractTask.php:209
‪TYPO3\CMS\Core\Resource\Processing\AbstractTask\getChecksumData
‪array getChecksumData()
Definition: AbstractTask.php:82
‪TYPO3\CMS\Core\Resource\Processing\AbstractTask\$name
‪string $name
Definition: AbstractTask.php:54
‪TYPO3\CMS\Core\Resource\Processing\AbstractTask\$successful
‪bool $successful
Definition: AbstractTask.php:62
‪TYPO3\CMS\Core\Resource\Processing
Definition: AbstractGraphicalTask.php:16
‪TYPO3\CMS\Core\Resource\Processing\AbstractTask\getTargetFilename
‪string getTargetFilename()
Definition: AbstractTask.php:106
‪TYPO3\CMS\Core\Resource\Processing\AbstractTask\isExecuted
‪bool isExecuted()
Definition: AbstractTask.php:198
‪TYPO3\CMS\Core\Resource\File
Definition: File.php:24
‪TYPO3\CMS\Core\Resource\Processing\AbstractTask\getTargetFile
‪Resource ProcessedFile getTargetFile()
Definition: AbstractTask.php:147
‪TYPO3\CMS\Core\Resource\AbstractFile\getUid
‪int getUid()
Definition: AbstractFile.php:202
‪TYPO3\CMS\Core\Resource\Processing\AbstractTask\$sourceFile
‪Resource File $sourceFile
Definition: AbstractTask.php:42
‪TYPO3\CMS\Core\Resource\Processing\AbstractTask\getSourceFile
‪Resource File getSourceFile()
Definition: AbstractTask.php:163
‪TYPO3\CMS\Core\Resource\Processing\AbstractTask\getConfigurationChecksum
‪string getConfigurationChecksum()
Definition: AbstractTask.php:96
‪TYPO3\CMS\Core\Resource
Definition: generateMimeTypes.php:52
‪TYPO3\CMS\Core\Resource\ProcessedFile
Definition: ProcessedFile.php:44
‪TYPO3\CMS\Core\Resource\Processing\AbstractTask\$configuration
‪array $configuration
Definition: AbstractTask.php:46
‪TYPO3\CMS\Core\Resource\Processing\AbstractTask\getType
‪string getType()
Definition: AbstractTask.php:139
‪TYPO3\CMS\Core\Resource\Processing\AbstractTask
Definition: AbstractTask.php:31
‪TYPO3\CMS\Core\Resource\Processing\AbstractTask\setTargetFile
‪setTargetFile(ProcessedFile $targetFile)
Definition: AbstractTask.php:155
‪TYPO3\CMS\Core\Resource\Processing\AbstractTask\isValidConfiguration
‪bool isValidConfiguration(array $configuration)
‪TYPO3\CMS\Core\Resource\Processing\AbstractTask\__construct
‪__construct(ProcessedFile $targetFile, array $configuration)
Definition: AbstractTask.php:68
‪TYPO3\CMS\Core\Resource\Processing\AbstractTask\isSuccessful
‪bool isSuccessful()
Definition: AbstractTask.php:221
‪TYPO3\CMS\Core\Resource\Processing\AbstractTask\$type
‪string $type
Definition: AbstractTask.php:50
‪TYPO3\CMS\Core\Resource\Processing\AbstractTask\setSourceFile
‪setSourceFile(File $sourceFile)
Definition: AbstractTask.php:171
‪TYPO3\CMS\Core\Resource\Processing\AbstractTask\$executed
‪bool $executed
Definition: AbstractTask.php:58
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Resource\Processing\AbstractTask\getConfiguration
‪array getConfiguration()
Definition: AbstractTask.php:179