‪TYPO3CMS  11.5
CleanupRedirectsCommand.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\InputInterface;
22 use Symfony\Component\Console\Input\InputOption;
23 use Symfony\Component\Console\Output\OutputInterface;
28 
29 class ‪CleanupRedirectsCommand extends Command
30 {
34  protected ‪$redirectRepository;
35 
40 
42  {
43  $this->redirectRepository = ‪$redirectRepository;
44  $this->languageService = $languageServiceFactory->‪create('default');
45  parent::__construct(null);
46  }
47 
48  protected function ‪configure(): void
49  {
50  $this
51  ->addOption(
52  'domain',
53  'd',
54  InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
55  $this->languageService->sL('LLL:EXT:redirects/Resources/Private/Language/locallang.xlf:cleanupRedirectsCommand.label.domain'),
56  null
57  )
58  ->addOption(
59  'statusCode',
60  's',
61  InputOption::VALUE_OPTIONAL | InputOption::VALUE_IS_ARRAY,
62  $this->languageService->sL('LLL:EXT:redirects/Resources/Private/Language/locallang.xlf:cleanupRedirectsCommand.label.statusCode'),
63  null
64  )
65  ->addOption(
66  'days',
67  'a',
68  InputOption::VALUE_OPTIONAL,
69  $this->languageService->sL('LLL:EXT:redirects/Resources/Private/Language/locallang.xlf:cleanupRedirectsCommand.label.days'),
70  null
71  )
72  ->addOption(
73  'hitCount',
74  'c',
75  InputOption::VALUE_OPTIONAL,
76  $this->languageService->sL('LLL:EXT:redirects/Resources/Private/Language/locallang.xlf:cleanupRedirectsCommand.label.hitCount'),
77  null
78  )
79  ->addOption(
80  'path',
81  'p',
82  InputOption::VALUE_OPTIONAL,
83  $this->languageService->sL('LLL:EXT:redirects/Resources/Private/Language/locallang.xlf:cleanupRedirectsCommand.label.path'),
84  null
85  )
86  ;
87  }
88 
89  protected function ‪execute(InputInterface $input, OutputInterface ‪$output): int
90  {
91  $this->redirectRepository->removeByDemand(‪Demand::fromCommandInput($input));
92  return 0;
93  }
94 }
‪TYPO3\CMS\Redirects\Repository\Demand
Definition: Demand.php:28
‪TYPO3\CMS\Core\Localization\LanguageServiceFactory
Definition: LanguageServiceFactory.php:25
‪TYPO3\CMS\Redirects\Command\CleanupRedirectsCommand\$redirectRepository
‪RedirectRepository $redirectRepository
Definition: CleanupRedirectsCommand.php:33
‪TYPO3\CMS\Redirects\Command\CleanupRedirectsCommand\execute
‪execute(InputInterface $input, OutputInterface $output)
Definition: CleanupRedirectsCommand.php:87
‪TYPO3\CMS\Core\Localization\LanguageServiceFactory\create
‪LanguageService create(string $locale)
Definition: LanguageServiceFactory.php:46
‪TYPO3\CMS\Redirects\Command
Definition: CheckIntegrityCommand.php:18
‪TYPO3\CMS\Redirects\Command\CleanupRedirectsCommand\__construct
‪__construct(RedirectRepository $redirectRepository, LanguageServiceFactory $languageServiceFactory)
Definition: CleanupRedirectsCommand.php:39
‪TYPO3\CMS\Redirects\Repository\RedirectRepository
Definition: RedirectRepository.php:31
‪$output
‪$output
Definition: annotationChecker.php:121
‪TYPO3\CMS\Redirects\Repository\Demand\fromCommandInput
‪static fromCommandInput(InputInterface $input)
Definition: Demand.php:127
‪TYPO3\CMS\Redirects\Command\CleanupRedirectsCommand\configure
‪configure()
Definition: CleanupRedirectsCommand.php:46
‪TYPO3\CMS\Core\Localization\LanguageService
Definition: LanguageService.php:42
‪TYPO3\CMS\Redirects\Command\CleanupRedirectsCommand\$languageService
‪LanguageService $languageService
Definition: CleanupRedirectsCommand.php:37
‪TYPO3\CMS\Redirects\Command\CleanupRedirectsCommand
Definition: CleanupRedirectsCommand.php:30