Completed
Push — development ( deb2fc...28a639 )
by Torben
04:28 queued 25s
created

CleanupCommandController   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 76
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 4
dl 0
loc 76
ccs 10
cts 10
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A injectConfigurationManager() 0 5 1
A injectRegistrationService() 0 4 1
A injectUtilityService() 0 4 1
A cleanupCommand() 0 16 1
1
<?php
2
namespace DERHANSEN\SfEventMgt\Command;
3
4
/*
5
 * This file is part of the TYPO3 CMS project.
6
 *
7
 * It is free software; you can redistribute it and/or modify it under
8
 * the terms of the GNU General Public License, either version 2
9
 * of the License, or any later version.
10
 *
11
 * For the full copyright and license information, please read the
12
 * LICENSE.txt file that was distributed with this source code.
13
 *
14
 * The TYPO3 project - inspiring people to share!
15
 */
16
17
use \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
18
19
/**
20
 * Class CleanupCommandController
21
 *
22
 * @author Torben Hansen <[email protected]>
23
 */
24
class CleanupCommandController extends \TYPO3\CMS\Extbase\Mvc\Controller\CommandController
25
{
26
    /**
27
     * Configurationmanager
28
     *
29
     * @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
30
     */
31
    protected $configurationManager;
32
33
    /**
34
     * UtilityService
35
     *
36
     * @var \DERHANSEN\SfEventMgt\Service\UtilityService
37
     */
38
    protected $utilityService = null;
39
40
    /**
41
     * Registrationservice
42
     *
43
     * @var \DERHANSEN\SfEventMgt\Service\RegistrationService
44
     */
45
    protected $registrationService;
46
47
    /**
48
     * DI for $configurationManager
49
     *
50
     * @param ConfigurationManagerInterface $configurationManager
51
     */
52
    public function injectConfigurationManager(
53
        \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager
54
    ) {
55
        $this->configurationManager = $configurationManager;
56 1
    }
57
58 1
    /**
59 1
     * DI for $registrationService
60 1
     *
61
     * @param \DERHANSEN\SfEventMgt\Service\RegistrationService $registrationService
62 1
     */
63
    public function injectRegistrationService(\DERHANSEN\SfEventMgt\Service\RegistrationService $registrationService)
64 1
    {
65 1
        $this->registrationService = $registrationService;
66 1
    }
67
68
    /**
69 1
     * DI for $utilityService
70 1
     *
71
     * @param \DERHANSEN\SfEventMgt\Service\UtilityService $utilityService
72
     */
73
    public function injectUtilityService(\DERHANSEN\SfEventMgt\Service\UtilityService $utilityService)
74
    {
75
        $this->utilityService = $utilityService;
76
    }
77
78
    /**
79
     * The cleanup command
80
     *
81
     * @return void
82
     */
83
    public function cleanupCommand()
84
    {
85
        $fullSettings = $this->configurationManager->getConfiguration(
86
            ConfigurationManagerInterface::CONFIGURATION_TYPE_FULL_TYPOSCRIPT,
87
            'SfEventMgt',
88
            'Pievent'
89
        );
90
91
        $settings = $fullSettings['plugin.']['tx_sfeventmgt.']['settings.'];
92
        $this->registrationService->handleExpiredRegistrations(
93
            $settings['registration.']['deleteExpiredRegistrations']
94
        );
95
96
        // Clear cache for configured pages
97
        $this->utilityService->clearCacheForConfiguredUids($settings);
98
    }
99
}
100