Completed
Push — typo3-10-compatibility ( b4f2e1...42d8ec )
by Torben
03:17
created

AbstractController   A

Complexity

Total Complexity 19

Size/Duplication

Total Lines 268
Duplicated Lines 0 %

Coupling/Cohesion

Components 14
Dependencies 2

Importance

Changes 0
Metric Value
wmc 19
lcom 14
cbo 2
dl 0
loc 268
rs 10
c 0
b 0
f 0

15 Methods

Rating   Name   Duplication   Size   Complexity  
A injectCalendarService() 0 4 1
A injectCategoryRepository() 0 5 1
A injectEventRepository() 0 4 1
A injectHashService() 0 4 1
A injectIcalendarService() 0 4 1
A injectLocationRepository() 0 5 1
A injectNotificationService() 0 4 1
A injectOrganisatorRepository() 0 5 1
A injectSpeakerRepository() 0 5 1
A injectPaymentService() 0 4 1
A injectRegistrationRepository() 0 5 1
A injectRegistrationService() 0 4 1
A injectFieldRepository() 0 5 1
A getTypoScriptFrontendController() 0 4 2
A overwriteEventDemandObject() 0 15 4
1
<?php
2
namespace DERHANSEN\SfEventMgt\Controller;
3
4
/*
5
 * This file is part of the Extension "sf_event_mgt" for TYPO3 CMS.
6
 *
7
 * For the full copyright and license information, please read the
8
 * LICENSE.txt file that was distributed with this source code.
9
 */
10
11
use DERHANSEN\SfEventMgt\Domain\Model\Dto\EventDemand;
12
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
13
14
/**
15
 * EventController
16
 *
17
 * @author Torben Hansen <[email protected]>
18
 */
19
abstract class AbstractController extends ActionController
20
{
21
    /**
22
     * Properties in this array will be ignored by overwriteDemandObject()
23
     *
24
     * @var array
25
     */
26
    protected $ignoredSettingsForOverwriteDemand = ['storagepage', 'orderfieldallowed'];
27
28
    /**
29
     * EventRepository
30
     *
31
     * @var \DERHANSEN\SfEventMgt\Domain\Repository\EventRepository
32
     */
33
    protected $eventRepository = null;
34
35
    /**
36
     * Registration repository
37
     *
38
     * @var \DERHANSEN\SfEventMgt\Domain\Repository\RegistrationRepository
39
     */
40
    protected $registrationRepository = null;
41
42
    /**
43
     * Category repository
44
     *
45
     * @var \DERHANSEN\SfEventMgt\Domain\Repository\CategoryRepository
46
     */
47
    protected $categoryRepository = null;
48
49
    /**
50
     * Location repository
51
     *
52
     * @var \DERHANSEN\SfEventMgt\Domain\Repository\LocationRepository
53
     */
54
    protected $locationRepository = null;
55
56
    /**
57
     * Organisator repository
58
     *
59
     * @var \DERHANSEN\SfEventMgt\Domain\Repository\OrganisatorRepository
60
     */
61
    protected $organisatorRepository = null;
62
63
    /**
64
     * Speaker repository
65
     *
66
     * @var \DERHANSEN\SfEventMgt\Domain\Repository\SpeakerRepository
67
     */
68
    protected $speakerRepository = null;
69
70
    /**
71
     * Notification Service
72
     *
73
     * @var \DERHANSEN\SfEventMgt\Service\NotificationService
74
     */
75
    protected $notificationService = null;
76
77
    /**
78
     * ICalendar Service
79
     *
80
     * @var \DERHANSEN\SfEventMgt\Service\ICalendarService
81
     */
82
    protected $icalendarService = null;
83
84
    /**
85
     * Hash Service
86
     *
87
     * @var \TYPO3\CMS\Extbase\Security\Cryptography\HashService
88
     */
89
    protected $hashService;
90
91
    /**
92
     * RegistrationService
93
     *
94
     * @var \DERHANSEN\SfEventMgt\Service\RegistrationService
95
     */
96
    protected $registrationService = null;
97
98
    /**
99
     * CalendarService
100
     *
101
     * @var \DERHANSEN\SfEventMgt\Service\CalendarService
102
     */
103
    protected $calendarService = null;
104
105
    /**
106
     * PaymentMethodService
107
     *
108
     * @var \DERHANSEN\SfEventMgt\Service\PaymentService
109
     */
110
    protected $paymentService = null;
111
112
    /**
113
     * FieldRepository
114
     *
115
     * @var \DERHANSEN\SfEventMgt\Domain\Repository\Registration\FieldRepository
116
     */
117
    protected $fieldRepository = null;
118
119
    /**
120
     * DI for $calendarService
121
     *
122
     * @param \DERHANSEN\SfEventMgt\Service\CalendarService $calendarService
123
     */
124
    public function injectCalendarService(\DERHANSEN\SfEventMgt\Service\CalendarService $calendarService)
125
    {
126
        $this->calendarService = $calendarService;
127
    }
128
129
    /**
130
     * DI for $categoryRepository
131
     *
132
     * @param \DERHANSEN\SfEventMgt\Domain\Repository\CategoryRepository $categoryRepository
133
     */
134
    public function injectCategoryRepository(
135
        \DERHANSEN\SfEventMgt\Domain\Repository\CategoryRepository $categoryRepository
136
    ) {
137
        $this->categoryRepository = $categoryRepository;
138
    }
139
140
    /**
141
     * DI for $eventRepository
142
     *
143
     * @param \DERHANSEN\SfEventMgt\Domain\Repository\EventRepository $eventRepository
144
     */
145
    public function injectEventRepository(\DERHANSEN\SfEventMgt\Domain\Repository\EventRepository $eventRepository)
146
    {
147
        $this->eventRepository = $eventRepository;
148
    }
149
150
    /**
151
     * DI for $hashService
152
     *
153
     * @param \TYPO3\CMS\Extbase\Security\Cryptography\HashService $hashService
154
     */
155
    public function injectHashService(\TYPO3\CMS\Extbase\Security\Cryptography\HashService $hashService)
156
    {
157
        $this->hashService = $hashService;
158
    }
159
160
    /**
161
     * DI for $icalendarService
162
     *
163
     * @param \DERHANSEN\SfEventMgt\Service\ICalendarService $icalendarService
164
     */
165
    public function injectIcalendarService(\DERHANSEN\SfEventMgt\Service\ICalendarService $icalendarService)
166
    {
167
        $this->icalendarService = $icalendarService;
168
    }
169
170
    /**
171
     * DI for $locationRepository
172
     *
173
     * @param \DERHANSEN\SfEventMgt\Domain\Repository\LocationRepository $locationRepository
174
     */
175
    public function injectLocationRepository(
176
        \DERHANSEN\SfEventMgt\Domain\Repository\LocationRepository $locationRepository
177
    ) {
178
        $this->locationRepository = $locationRepository;
179
    }
180
181
    /**
182
     * DI for $notificationService
183
     *
184
     * @param \DERHANSEN\SfEventMgt\Service\NotificationService $notificationService
185
     */
186
    public function injectNotificationService(\DERHANSEN\SfEventMgt\Service\NotificationService $notificationService)
187
    {
188
        $this->notificationService = $notificationService;
189
    }
190
191
    /**
192
     * DI for $organisatorRepository
193
     *
194
     * @param \DERHANSEN\SfEventMgt\Domain\Repository\OrganisatorRepository $organisatorRepository
195
     */
196
    public function injectOrganisatorRepository(
197
        \DERHANSEN\SfEventMgt\Domain\Repository\OrganisatorRepository $organisatorRepository
198
    ) {
199
        $this->organisatorRepository = $organisatorRepository;
200
    }
201
202
    /**
203
     * DI for $speakerRepository
204
     *
205
     * @param \DERHANSEN\SfEventMgt\Domain\Repository\SpeakerRepository $speakerRepository
206
     */
207
    public function injectSpeakerRepository(
208
        \DERHANSEN\SfEventMgt\Domain\Repository\SpeakerRepository $speakerRepository
209
    ) {
210
        $this->speakerRepository = $speakerRepository;
211
    }
212
213
    /**
214
     * DI for $paymentService
215
     *
216
     * @param \DERHANSEN\SfEventMgt\Service\PaymentService $paymentService
217
     */
218
    public function injectPaymentService(\DERHANSEN\SfEventMgt\Service\PaymentService $paymentService)
219
    {
220
        $this->paymentService = $paymentService;
221
    }
222
223
    /**
224
     * DI for $registrationRepository
225
     *
226
     * @param \DERHANSEN\SfEventMgt\Domain\Repository\RegistrationRepository $registrationRepository
227
     */
228
    public function injectRegistrationRepository(
229
        \DERHANSEN\SfEventMgt\Domain\Repository\RegistrationRepository $registrationRepository
230
    ) {
231
        $this->registrationRepository = $registrationRepository;
232
    }
233
234
    /**
235
     * DI for $registrationService
236
     *
237
     * @param \DERHANSEN\SfEventMgt\Service\RegistrationService $registrationService
238
     */
239
    public function injectRegistrationService(\DERHANSEN\SfEventMgt\Service\RegistrationService $registrationService)
240
    {
241
        $this->registrationService = $registrationService;
242
    }
243
244
    /**
245
     * DI for $fieldRepository
246
     *
247
     * @param \DERHANSEN\SfEventMgt\Domain\Repository\Registration\FieldRepository $fieldRepository
248
     */
249
    public function injectFieldRepository(
250
        \DERHANSEN\SfEventMgt\Domain\Repository\Registration\FieldRepository $fieldRepository
251
    ) {
252
        $this->fieldRepository = $fieldRepository;
253
    }
254
255
    /**
256
     * @return \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
257
     */
258
    protected function getTypoScriptFrontendController()
259
    {
260
        return $GLOBALS['TSFE'] ?: null;
261
    }
262
263
    /**
264
     * Overwrites a given demand object by an propertyName =>  $propertyValue array
265
     *
266
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Dto\EventDemand $demand Demand
267
     * @param array $overwriteDemand OwerwriteDemand
268
     *
269
     * @return \DERHANSEN\SfEventMgt\Domain\Model\Dto\EventDemand
270
     */
271
    protected function overwriteEventDemandObject(EventDemand $demand, array $overwriteDemand)
272
    {
273
        foreach ($this->ignoredSettingsForOverwriteDemand as $property) {
274
            unset($overwriteDemand[$property]);
275
        }
276
277
        foreach ($overwriteDemand as $propertyName => $propertyValue) {
278
            if (in_array(strtolower($propertyName), $this->ignoredSettingsForOverwriteDemand, true)) {
279
                continue;
280
            }
281
            \TYPO3\CMS\Extbase\Reflection\ObjectAccess::setProperty($demand, $propertyName, $propertyValue);
282
        }
283
284
        return $demand;
285
    }
286
}
287