CleanupGdprCommand   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 25
c 1
b 0
f 0
dl 0
loc 36
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 12 1
A configure() 0 19 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\InputArgument;
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
class CleanupGdprCommand extends Command
24
{
25
    public function configure(): void
26
    {
27
        $this
28
            ->addArgument(
29
                'days',
30
                InputArgument::REQUIRED,
31
                'Amount of days reduced from todays date for expired event selection'
32
            )
33
            ->addOption(
34
                'softDelete',
35
                's',
36
                InputOption::VALUE_NONE,
37
                'If set, registration will not be deleted hard, but only flagged as deleted'
38
            )
39
            ->addOption(
40
                'ignoreEventRestriction',
41
                'i',
42
                InputOption::VALUE_NONE,
43
                'If set, simply all available registrations will be selected and deleted. Use with care!'
44
            );
45
    }
46
47
    protected function execute(InputInterface $input, OutputInterface $output): int
48
    {
49
        $maintenanceService = GeneralUtility::makeInstance(MaintenanceService::class);
50
        $io = new SymfonyStyle($input, $output);
51
        $io->title($this->getDescription());
52
        $days = (int)$input->getArgument('days');
53
        $softDelete = (bool)$input->getOption('softDelete');
54
        $ignoreEventRestriction = (bool)$input->getOption('ignoreEventRestriction');
55
        $amountDeleted = $maintenanceService->processGdprCleanup($days, $softDelete, $ignoreEventRestriction);
56
        $io->success($amountDeleted . ' registrations deleted.');
57
58
        return Command::SUCCESS;
59
    }
60
}
61