‪TYPO3CMS  ‪main
FileStorageExtractionTask.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 
28 {
34  public ‪$storageUid = -1;
35 
41  public ‪$maxFileCount = 100;
42 
48  public function ‪execute()
49  {
50  $success = false;
51  if ((int)$this->storageUid > 0) {
52  $storage = GeneralUtility::makeInstance(StorageRepository::class)->findByUid($this->storageUid);
53  if ($storage === null) {
54  throw new \RuntimeException(self::class . ' misconfiguration: "Storage to index" must be an existing storage.', 1615020909);
55  }
56  $currentEvaluatePermissionsValue = $storage->getEvaluatePermissions();
57  $storage->setEvaluatePermissions(false);
58  $indexer = $this->‪getIndexer($storage);
59  try {
60  $indexer->runMetaDataExtraction((int)$this->maxFileCount);
61  $success = true;
62  } catch (\‪Exception $e) {
63  $success = false;
64  $this->‪logException($e);
65  }
66  $storage->setEvaluatePermissions($currentEvaluatePermissionsValue);
67  }
68  return $success;
69  }
70 
76  protected function ‪getIndexer(‪ResourceStorage $storage)
77  {
78  return GeneralUtility::makeInstance(Indexer::class, $storage);
79  }
80 }
‪TYPO3\CMS\Scheduler\Task\FileStorageExtractionTask\getIndexer
‪TYPO3 CMS Core Resource Index Indexer getIndexer(ResourceStorage $storage)
Definition: FileStorageExtractionTask.php:74
‪TYPO3\CMS\Scheduler\Task\FileStorageExtractionTask
Definition: FileStorageExtractionTask.php:28
‪TYPO3\CMS\Scheduler\Task\FileStorageExtractionTask\$maxFileCount
‪int $maxFileCount
Definition: FileStorageExtractionTask.php:39
‪TYPO3\CMS\Core\Resource\Index\Indexer
Definition: Indexer.php:35
‪TYPO3\CMS\Scheduler\Task
Definition: AbstractTask.php:16
‪TYPO3\CMS\Scheduler\Task\AbstractTask
Definition: AbstractTask.php:33
‪TYPO3\CMS\Core\Resource\StorageRepository
Definition: StorageRepository.php:38
‪TYPO3\CMS\Scheduler\Task\AbstractTask\logException
‪logException(\Exception $e)
Definition: AbstractTask.php:426
‪TYPO3\CMS\Scheduler\Exception
Definition: Exception.php:25
‪TYPO3\CMS\Core\Resource\ResourceStorage
Definition: ResourceStorage.php:129
‪TYPO3\CMS\Scheduler\Task\FileStorageExtractionTask\$storageUid
‪int $storageUid
Definition: FileStorageExtractionTask.php:33
‪TYPO3\CMS\Scheduler\Task\FileStorageExtractionTask\execute
‪bool execute()
Definition: FileStorageExtractionTask.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52