[TASK] Re-work/simplify copyright header in PHP files - Part 9
[Packages/TYPO3.CMS.git] / typo3 / sysext / scheduler / Classes / Task / FileStorageIndexingTask.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 * This task tries to find changes in storage and writes them back to DB
18 *
19 */
20 class FileStorageIndexingTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask {
21
22 /**
23 * Storage Uid
24 *
25 * @var integer
26 */
27 public $storageUid = -1;
28
29 /**
30 * Function execute from the Scheduler
31 *
32 * @return boolean TRUE on successful execution, FALSE on error
33 */
34 public function execute() {
35 $success = FALSE;
36 if ((int)$this->storageUid > 0) {
37 $storage = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getStorageObject($this->storageUid);
38 $storage->setEvaluatePermissions(FALSE);
39 $indexer = $this->getIndexer($storage);
40 try {
41 $indexer->processChangesInStorages();
42 $success = TRUE;
43 } catch (\Exception $e) {
44 $success = FALSE;
45 }
46 $storage->setEvaluatePermissions(TRUE);
47 }
48 return $success;
49 }
50
51 /**
52 * Gets the indexer
53 *
54 * @param \TYPO3\CMS\Core\Resource\ResourceStorage $storage
55 * @return \TYPO3\CMS\Core\Resource\Index\Indexer
56 */
57 protected function getIndexer(\TYPO3\CMS\Core\Resource\ResourceStorage $storage) {
58 return \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\Index\\Indexer', $storage);
59 }
60
61
62 }