Completed
Push — development ( f86da0...2b08b7 )
by Torben
03:17
created

AbstractController::injectPaymentService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

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