[TASK] Use fully qualified name resolution in PHP 5.5
[Packages/TYPO3.CMS.git] / typo3 / sysext / scheduler / Classes / Task / FileStorageExtractionTask.php
1 <?php
2 namespace TYPO3\CMS\Scheduler\Task;
3
4 /**
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * This task which indexes files in storage
19 */
20 class FileStorageExtractionTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
21
22 /**
23 * Storage Uid
24 *
25 * @var int
26 */
27 public $storageUid = -1;
28
29 /**
30 * FileCount
31 *
32 * @var int
33 */
34 public $maxFileCount = 100;
35
36 /**
37 * Function execute from the Scheduler
38 *
39 * @return bool TRUE on successful execution, FALSE on error
40 */
41 public function execute() {
42 $success = FALSE;
43 if ((int)$this->storageUid > 0) {
44 $storage = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getStorageObject($this->storageUid);
45 $storage->setEvaluatePermissions(FALSE);
46 $indexer = $this->getIndexer($storage);
47 try {
48 $indexer->runMetaDataExtraction((int)$this->maxFileCount);
49 $success = TRUE;
50 } catch (\Exception $e) {
51 $success = FALSE;
52 }
53 $storage->setEvaluatePermissions(TRUE);
54 }
55 return $success;
56 }
57
58 /**
59 * Gets the indexer
60 *
61 * @param \TYPO3\CMS\Core\Resource\ResourceStorage $storage
62 * @return \TYPO3\CMS\Core\Resource\Index\Indexer
63 */
64 protected function getIndexer(\TYPO3\CMS\Core\Resource\ResourceStorage $storage) {
65 return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\Index\Indexer::class, $storage);
66 }
67
68 }