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
|
|
|
/** |
24
|
|
|
* Class CleanupGdprCommand |
25
|
|
|
*/ |
26
|
|
|
class CleanupGdprCommand extends Command |
27
|
|
|
{ |
28
|
|
|
/** |
29
|
|
|
* Configuring the command options |
30
|
|
|
*/ |
31
|
|
|
public function configure() |
32
|
|
|
{ |
33
|
|
|
$this |
34
|
|
|
->setDescription( |
35
|
|
|
'Delete registrations of expired events.' |
36
|
|
|
) |
37
|
|
|
->addArgument( |
38
|
|
|
'days', |
39
|
|
|
InputArgument::REQUIRED, |
40
|
|
|
'Amount of days reduced from todays date for expired event selection' |
41
|
|
|
) |
42
|
|
|
->addOption( |
43
|
|
|
'softDelete', |
44
|
|
|
's', |
45
|
|
|
InputOption::VALUE_NONE, |
46
|
|
|
'If set, registration will not be deleted hard, but only flagged as deleted', |
47
|
|
|
) |
48
|
|
|
->addOption( |
49
|
|
|
'ignoreEventRestriction', |
50
|
|
|
'i', |
51
|
|
|
InputOption::VALUE_NONE, |
52
|
|
|
'If set, simply all available registrations will be selected and deleted. Use with care!', |
53
|
|
|
); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Execute the cleanup command |
58
|
|
|
* |
59
|
|
|
* @param InputInterface $input |
60
|
|
|
* @param OutputInterface $output |
61
|
|
|
* @return int |
62
|
|
|
*/ |
63
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
64
|
|
|
{ |
65
|
|
|
$maintenanceService = GeneralUtility::makeInstance(MaintenanceService::class); |
66
|
|
|
$io = new SymfonyStyle($input, $output); |
67
|
|
|
$io->title($this->getDescription()); |
68
|
|
|
$days = (int)$input->getArgument('days'); |
69
|
|
|
$softDelete = (bool)$input->getOption('softDelete'); |
70
|
|
|
$ignoreEventRestriction = (bool)$input->getOption('ignoreEventRestriction'); |
71
|
|
|
$amountDeleted = $maintenanceService->processGdprCleanup($days, $softDelete, $ignoreEventRestriction); |
72
|
|
|
$io->success($amountDeleted . ' registrations deleted.'); |
73
|
|
|
|
74
|
|
|
return 0; |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|