‪TYPO3CMS  11.5
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;
26 
27 class ‪CheckIntegrityCommand extends Command
28 {
29  private const ‪REGISTRY_NAMESPACE = 'tx_redirects';
30  private const ‪REGISTRY_KEY = 'conflicting_redirects';
31 
35  private ‪$registry;
36 
41 
43  {
44  $this->registry = ‪$registry;
45  $this->integrityService = ‪$integrityService;
46  parent::__construct();
47  }
48 
49  protected function ‪configure(): void
50  {
51  $this->addArgument(
52  'site',
53  InputArgument::OPTIONAL,
54  'If set, then only pages of a specific site are checked',
55  ''
56  );
57  }
58 
62  protected function ‪execute(InputInterface $input, OutputInterface ‪$output): int
63  {
64  $this->registry->remove(self::REGISTRY_NAMESPACE, self::REGISTRY_KEY);
65 
66  $list = [];
67  $site = $input->getArgument('site') ?: null;
68  foreach ($this->integrityService->findConflictingRedirects($site) as $conflict) {
69  $list[] = $conflict;
70  ‪$output->writeln(sprintf(
71  'Redirect (Host: %s, Path: %s) conflicts with %s',
72  $conflict['redirect']['source_host'],
73  $conflict['redirect']['source_path'],
74  $conflict['uri']
75  ));
76  }
77  $this->registry->set(self::REGISTRY_NAMESPACE, self::REGISTRY_KEY, $list);
78  return 0;
79  }
80 }
‪TYPO3\CMS\Redirects\Command\CheckIntegrityCommand\__construct
‪__construct(Registry $registry, IntegrityService $integrityService)
Definition: CheckIntegrityCommand.php:40
‪TYPO3\CMS\Redirects\Command\CheckIntegrityCommand\execute
‪execute(InputInterface $input, OutputInterface $output)
Definition: CheckIntegrityCommand.php:60
‪TYPO3\CMS\Redirects\Command\CheckIntegrityCommand\REGISTRY_NAMESPACE
‪const REGISTRY_NAMESPACE
Definition: CheckIntegrityCommand.php:29
‪TYPO3\CMS\Core\Registry
Definition: Registry.php:33
‪TYPO3\CMS\Redirects\Command
Definition: CheckIntegrityCommand.php:18
‪TYPO3\CMS\Redirects\Command\CheckIntegrityCommand
Definition: CheckIntegrityCommand.php:28
‪TYPO3\CMS\Redirects\Command\CheckIntegrityCommand\REGISTRY_KEY
‪const REGISTRY_KEY
Definition: CheckIntegrityCommand.php:30
‪$output
‪$output
Definition: annotationChecker.php:121
‪TYPO3\CMS\Redirects\Command\CheckIntegrityCommand\$registry
‪Registry $registry
Definition: CheckIntegrityCommand.php:34
‪TYPO3\CMS\Redirects\Command\CheckIntegrityCommand\$integrityService
‪IntegrityService $integrityService
Definition: CheckIntegrityCommand.php:38
‪TYPO3\CMS\Redirects\Command\CheckIntegrityCommand\configure
‪configure()
Definition: CheckIntegrityCommand.php:47
‪TYPO3\CMS\Redirects\Service\IntegrityService
Definition: IntegrityService.php:32