Passed
Push — 5.x ( 443321...10bf12 )
by Torben
45:10
created

CleanupExpiredCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 11
rs 10
c 0
b 0
f 0
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\Command\Command;
16
use Symfony\Component\Console\Input\InputInterface;
17
use Symfony\Component\Console\Input\InputOption;
18
use Symfony\Component\Console\Output\OutputInterface;
19
use Symfony\Component\Console\Style\SymfonyStyle;
20
use TYPO3\CMS\Core\Utility\GeneralUtility;
21
22
/**
23
 * Class CleanupCommand
24
 */
25
class CleanupExpiredCommand extends Command
26
{
27
    /**
28
     * Configuring the command options
29
     */
30
    public function configure()
31
    {
32
        $this
33
            ->setDescription(
34
                'Cleanup registrations which are not confirmed and where the confirmation date is expired.'
35
            )
36
            ->addOption(
37
                'delete',
38
                'd',
39
                InputOption::VALUE_NONE,
40
                'If set, registrations will be set to deleted instead of hidden'
41
            );
42
    }
43
44
    /**
45
     * Execute the cleanup command
46
     *
47
     * @param InputInterface $input
48
     * @param OutputInterface $output
49
     * @return int|void|null
50
     */
51
    protected function execute(InputInterface $input, OutputInterface $output)
52
    {
53
        $maintenanceService = GeneralUtility::makeInstance(MaintenanceService::class);
54
        $io = new SymfonyStyle($input, $output);
55
        $io->title($this->getDescription());
56
        $delete = (bool)$input->getOption('delete');
57
        $maintenanceService->handleExpiredRegistrations($delete);
58
        $io->success('All done!');
59
60
        return 0;
61
    }
62
}
63