Completed
Push — master ( 2700b4...4ccb05 )
by Torben
04:03 queued 02:37
created

CleanupCommand   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 4
dl 0
loc 34
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 11 1
A execute() 0 9 3
1
<?php
2
declare(strict_types = 1);
3
namespace DERHANSEN\SfEventMgt\Command;
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
use DERHANSEN\SfEventMgt\Service\MaintenanceService;
13
use Symfony\Component\Console\Command\Command;
14
use Symfony\Component\Console\Input\InputInterface;
15
use Symfony\Component\Console\Input\InputOption;
16
use Symfony\Component\Console\Output\OutputInterface;
17
use Symfony\Component\Console\Style\SymfonyStyle;
18
use TYPO3\CMS\Core\Utility\GeneralUtility;
19
20
/**
21
 * Class CleanupCommand
22
 *
23
 * @author Torben Hansen <[email protected]>
24
 */
25
class CleanupCommand extends Command
26
{
27
    /**
28
     * Configuring the command options
29
     */
30
    public function configure()
31
    {
32
        $this
33
            ->setDescription('Cleanup registrations which are not confirmed and where the confirmation date is expired.')
34
            ->addOption(
35
                'delete',
36
                'd',
37
                InputOption::VALUE_NONE,
38
                'If set, registrations will be set to deleted instead of hidden'
39
            );
40
    }
41
42
    /**
43
     * Execute the cleanup command
44
     *
45
     * @param InputInterface $input
46
     * @param OutputInterface $output
47
     * @return int|void|null
48
     */
49
    protected function execute(InputInterface $input, OutputInterface $output)
50
    {
51
        $maintenanceService = GeneralUtility::makeInstance(MaintenanceService::class);
52
        $io = new SymfonyStyle($input, $output);
53
        $io->title($this->getDescription());
54
        $delete = $input->hasOption('delete') && $input->getOption('delete') ? true : false;
55
        $maintenanceService->handleExpiredRegistrations($delete);
56
        $io->success('All done!');
57
    }
58
}
59