CleanupExpiredCommand::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 10
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Extension "sf_event_mgt" for TYPO3 CMS.
7
 *
8
 * For the full copyright and license information, please read the
9
 * LICENSE.txt file that was distributed with this source code.
10
 */
11
12
namespace DERHANSEN\SfEventMgt\Command;
13
14
use DERHANSEN\SfEventMgt\Service\MaintenanceService;
15
use Symfony\Component\Console\Attribute\AsCommand;
16
use Symfony\Component\Console\Command\Command;
17
use Symfony\Component\Console\Input\InputInterface;
18
use Symfony\Component\Console\Input\InputOption;
19
use Symfony\Component\Console\Output\OutputInterface;
20
use Symfony\Component\Console\Style\SymfonyStyle;
21
use TYPO3\CMS\Core\Utility\GeneralUtility;
22
23
#[AsCommand(
24
    'sf_event_mgt:cleanup:expired',
25
    'Cleanup registrations which are not confirmed and where the confirmation date is expired.'
26
)]
27
class CleanupExpiredCommand extends Command
28
{
29
    public function configure(): void
30
    {
31
        $this->addOption(
32
            'delete',
33
            'd',
34
            InputOption::VALUE_NONE,
35
            'If set, registrations will be set to deleted instead of hidden'
36
        );
37
    }
38
39
    protected function execute(InputInterface $input, OutputInterface $output): int
40
    {
41
        $maintenanceService = GeneralUtility::makeInstance(MaintenanceService::class);
42
        $io = new SymfonyStyle($input, $output);
43
        $io->title($this->getDescription());
44
        $delete = (bool)$input->getOption('delete');
45
        $maintenanceService->handleExpiredRegistrations($delete);
46
        $io->success('All done!');
47
48
        return Command::SUCCESS;
49
    }
50
}
51