3 use \TYPO3\CMS\Core\Utility;
34 protected $objectType =
'TYPO3\\CMS\\Core\\Resource\\ProcessedFile';
42 protected $table =
'sys_file_processedfile';
59 $this->databaseConnection =
$GLOBALS[
'TYPO3_DB'];
84 $originalFile = $this->resourceFactory->getFileObject((
int)$databaseRow[
'original']);
85 $originalFile->setStorage($this->resourceFactory->getStorageObject($originalFile->getProperty(
'storage')));
86 $taskType = $databaseRow[
'task_type'];
87 $configuration = unserialize($databaseRow[
'configuration']);
105 $processedFileObject = NULL;
106 if ($storage->
hasFile($identifier)) {
107 $databaseRow = $this->databaseConnection->exec_SELECTgetSingleRow(
110 'storage = ' . (
int)$storage->
getUid() .
111 ' AND identifier = ' . $this->databaseConnection->fullQuoteStr($identifier, $this->table)
117 return $processedFileObject;
125 public function add($processedFile) {
126 if ($processedFile->isPersisted()) {
127 $this->
update($processedFile);
129 $insertFields = $processedFile->toArray();
130 $insertFields[
'crdate'] = $insertFields[
'tstamp'] = time();
132 $this->databaseConnection->exec_INSERTquery($this->table, $insertFields);
133 $uid = $this->databaseConnection->sql_insert_id();
134 $processedFile->updateProperties(array(
'uid' =>
$uid));
145 if ($processedFile->isPersisted()) {
146 $uid = (int)$processedFile->getUid();
148 $updateFields[
'tstamp'] = time();
149 $this->databaseConnection->exec_UPDATEquery($this->table,
'uid=' . (
int)
$uid, $updateFields);
161 $databaseRow = $this->databaseConnection->exec_SELECTgetSingleRow(
164 'original=' . (
int)$file->getUid() .
165 ' AND task_type=' . $this->databaseConnection->fullQuoteStr($taskType, $this->table) .
166 ' AND configurationsha1=' . $this->databaseConnection->fullQuoteStr(sha1(serialize($configuration)), $this->table)
169 if (is_array($databaseRow)) {
174 return $processedFile;
183 if (!$file instanceof
File) {
184 throw new \InvalidArgumentException(
'Parameter is no File object but got type "' 185 . (is_object($file) ? get_class($file) : gettype($file)) .
'"', 1382006142);
187 $whereClause =
'original=' . (int)$file->getUid();
188 $rows = $this->databaseConnection->exec_SELECTgetRows(
'*', $this->table, $whereClause);
191 if ($rows !== NULL) {
192 foreach ($rows as $row) {
206 $res = $this->databaseConnection->exec_SELECTquery(
'*', $this->table,
'identifier <> \'\'');
209 while ($row = $this->databaseConnection->sql_fetch_assoc($res)) {
210 if ($storageUid && (
int)$storageUid !== (int)$row[
'storage']) {
215 $file->getStorage()->setEvaluatePermissions(FALSE);
219 'Failed to delete file "' . $row[
'identifier'] .
'" in storage uid ' . $row[
'storage'] .
'.',
228 $this->databaseConnection->exec_TRUNCATEquery($this->table);
242 return array_intersect_key($data, $this->databaseConnection->admin_get_fields($this->table));
createNewProcessedFileObject(FileInterface $originalFile, $taskType, array $configuration)
static makeInstance($className)
createDomainObject(array $databaseRow)
findOneByOriginalFileAndTaskTypeAndConfiguration(FileInterface $file, $taskType, array $configuration)
findAllByOriginalFile(FileInterface $file)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
findByStorageAndIdentifier(ResourceStorage $storage, $identifier)
removeAll($storageUid=NULL)
cleanUnavailableColumns(array $data)