‪TYPO3CMS  10.4
CheckIntegrityCommand.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Symfony\Component\Console\Command\Command;
21 use Symfony\Component\Console\Input\InputArgument;
22 use Symfony\Component\Console\Input\InputInterface;
23 use Symfony\Component\Console\Output\OutputInterface;
27 
28 class ‪CheckIntegrityCommand extends Command
29 {
30  private const ‪REGISTRY_NAMESPACE = 'tx_redirects';
31  private const ‪REGISTRY_KEY = 'conflicting_redirects';
32 
33  protected function ‪configure(): void
34  {
35  $this
36  ->setDescription('Check integrity of redirects')
37  ->addArgument(
38  'site',
39  InputArgument::OPTIONAL,
40  'If set, then only pages of a specific site are checked',
41  ''
42  );
43  }
44 
52  protected function ‪execute(InputInterface $input, OutputInterface ‪$output)
53  {
54  $registry = GeneralUtility::makeInstance(Registry::class);
55  $registry->remove(static::REGISTRY_NAMESPACE, static::REGISTRY_KEY);
56 
57  $integrityService = GeneralUtility::makeInstance(IntegrityService::class);
58  $list = [];
59  $site = $input->getArgument('site') ?: null;
60  foreach ($integrityService->findConflictingRedirects($site) as $conflict) {
61  $list[] = $conflict;
62  ‪$output->writeln(sprintf(
63  'Redirect (Host: %s, Path: %s) conflicts with %s',
64  $conflict['redirect']['source_host'],
65  $conflict['redirect']['source_path'],
66  $conflict['uri']
67  ));
68  }
69  $registry->set(static::REGISTRY_NAMESPACE, static::REGISTRY_KEY, $list);
70  return 0;
71  }
72 }
‪TYPO3\CMS\Redirects\Command\CheckIntegrityCommand\execute
‪int execute(InputInterface $input, OutputInterface $output)
Definition: CheckIntegrityCommand.php:52
‪TYPO3\CMS\Redirects\Command\CheckIntegrityCommand\REGISTRY_NAMESPACE
‪const REGISTRY_NAMESPACE
Definition: CheckIntegrityCommand.php:30
‪TYPO3\CMS\Core\Registry
Definition: Registry.php:33
‪TYPO3\CMS\Redirects\Command
Definition: CheckIntegrityCommand.php:18
‪TYPO3\CMS\Redirects\Command\CheckIntegrityCommand
Definition: CheckIntegrityCommand.php:29
‪TYPO3\CMS\Redirects\Command\CheckIntegrityCommand\REGISTRY_KEY
‪const REGISTRY_KEY
Definition: CheckIntegrityCommand.php:31
‪$output
‪$output
Definition: annotationChecker.php:119
‪TYPO3\CMS\Redirects\Command\CheckIntegrityCommand\configure
‪configure()
Definition: CheckIntegrityCommand.php:33
‪TYPO3\CMS\Redirects\Service\IntegrityService
Definition: IntegrityService.php:31
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46