Passed
Push — master ( 0d18d8...40235e )
by Torben
28:04 queued 24:57
created

CleanupExpiredCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 7 1
A execute() 0 10 1
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 CleanupExpiredCommand
24
 */
25
class CleanupExpiredCommand extends Command
26
{
27
    /**
28
     * Configuring the command options
29
     */
30
    public function configure()
31
    {
32
        $this->addOption(
33
            'delete',
34
            'd',
35
            InputOption::VALUE_NONE,
36
            'If set, registrations will be set to deleted instead of hidden'
37
        );
38
    }
39
40
    /**
41
     * Execute the cleanup command
42
     *
43
     * @param InputInterface $input
44
     * @param OutputInterface $output
45
     * @return int
46
     */
47
    protected function execute(InputInterface $input, OutputInterface $output)
48
    {
49
        $maintenanceService = GeneralUtility::makeInstance(MaintenanceService::class);
50
        $io = new SymfonyStyle($input, $output);
51
        $io->title($this->getDescription());
52
        $delete = (bool)$input->getOption('delete');
53
        $maintenanceService->handleExpiredRegistrations($delete);
54
        $io->success('All done!');
55
56
        return 0;
57
    }
58
}
59