75be9a4863cd443af3c385af0ed167828583a249
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Command / ReferenceIndexUpdateCommand.php
1 <?php
2 namespace TYPO3\CMS\Backend\Command;
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 use Symfony\Component\Console\Command\Command;
18 use Symfony\Component\Console\Input\InputInterface;
19 use Symfony\Component\Console\Input\InputOption;
20 use Symfony\Component\Console\Output\OutputInterface;
21 use TYPO3\CMS\Core\Database\ReferenceIndex;
22 use TYPO3\CMS\Core\Utility\GeneralUtility;
23
24 /**
25 * Core function to check/update the Reference Index
26 */
27 class ReferenceIndexUpdateCommand extends Command
28 {
29 /**
30 * Configure the command by defining the name, options and arguments
31 */
32 public function configure()
33 {
34 $this->setDescription('Update the reference index of TYPO3')
35 ->addOption(
36 'check',
37 'c',
38 InputOption::VALUE_NONE,
39 'Only check the reference index of TYPO3'
40 );
41 }
42
43 /**
44 * Executes the command for adding or removing the lock file
45 *
46 * @param InputInterface $input
47 * @param OutputInterface $output
48 * @return void
49 */
50 protected function execute(InputInterface $input, OutputInterface $output)
51 {
52 $isTestOnly = $input->getOption('check');
53 $isSilent = $output->getVerbosity() !== OutputInterface::VERBOSITY_QUIET;
54
55 /** @var ReferenceIndex $referenceIndex */
56 $referenceIndex = GeneralUtility::makeInstance(ReferenceIndex::class);
57 $referenceIndex->updateIndex($isTestOnly, $isSilent);
58 }
59 }