|
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\Controller; |
|
13
|
|
|
|
|
14
|
|
|
use DERHANSEN\SfEventMgt\Domain\Model\Dto\EventDemand; |
|
15
|
|
|
use DERHANSEN\SfEventMgt\Domain\Repository\CategoryRepository; |
|
16
|
|
|
use DERHANSEN\SfEventMgt\Domain\Repository\EventRepository; |
|
17
|
|
|
use DERHANSEN\SfEventMgt\Domain\Repository\LocationRepository; |
|
18
|
|
|
use DERHANSEN\SfEventMgt\Domain\Repository\OrganisatorRepository; |
|
19
|
|
|
use DERHANSEN\SfEventMgt\Domain\Repository\Registration\FieldRepository; |
|
20
|
|
|
use DERHANSEN\SfEventMgt\Domain\Repository\RegistrationRepository; |
|
21
|
|
|
use DERHANSEN\SfEventMgt\Domain\Repository\SpeakerRepository; |
|
22
|
|
|
use DERHANSEN\SfEventMgt\Pagination\NumberedPagination; |
|
23
|
|
|
use DERHANSEN\SfEventMgt\Service\CalendarService; |
|
24
|
|
|
use DERHANSEN\SfEventMgt\Service\ICalendarService; |
|
25
|
|
|
use DERHANSEN\SfEventMgt\Service\NotificationService; |
|
26
|
|
|
use DERHANSEN\SfEventMgt\Service\PaymentService; |
|
27
|
|
|
use DERHANSEN\SfEventMgt\Service\RegistrationService; |
|
28
|
|
|
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; |
|
29
|
|
|
use TYPO3\CMS\Extbase\Mvc\Controller\Arguments; |
|
30
|
|
|
use TYPO3\CMS\Extbase\Pagination\QueryResultPaginator; |
|
31
|
|
|
use TYPO3\CMS\Extbase\Persistence\QueryResultInterface; |
|
32
|
|
|
use TYPO3\CMS\Extbase\Reflection\ObjectAccess; |
|
33
|
|
|
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; |
|
34
|
|
|
|
|
35
|
|
|
abstract class AbstractController extends ActionController |
|
36
|
|
|
{ |
|
37
|
|
|
protected array $ignoredSettingsForOverwriteDemand = ['storagepage', 'orderfieldallowed']; |
|
38
|
|
|
|
|
39
|
|
|
protected EventRepository $eventRepository; |
|
40
|
|
|
protected RegistrationRepository $registrationRepository; |
|
41
|
|
|
protected CategoryRepository $categoryRepository; |
|
42
|
|
|
protected LocationRepository $locationRepository; |
|
43
|
|
|
protected OrganisatorRepository $organisatorRepository; |
|
44
|
|
|
protected SpeakerRepository $speakerRepository; |
|
45
|
|
|
protected NotificationService $notificationService; |
|
46
|
|
|
protected ICalendarService $icalendarService; |
|
47
|
|
|
protected RegistrationService $registrationService; |
|
48
|
|
|
protected CalendarService $calendarService; |
|
49
|
|
|
protected PaymentService $paymentService; |
|
50
|
|
|
protected FieldRepository $fieldRepository; |
|
51
|
|
|
|
|
52
|
|
|
public function injectCalendarService(CalendarService $calendarService): void |
|
53
|
|
|
{ |
|
54
|
|
|
$this->calendarService = $calendarService; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function injectCategoryRepository(CategoryRepository $categoryRepository): void |
|
58
|
|
|
{ |
|
59
|
|
|
$this->categoryRepository = $categoryRepository; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
public function injectEventRepository(EventRepository $eventRepository): void |
|
63
|
|
|
{ |
|
64
|
|
|
$this->eventRepository = $eventRepository; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function injectIcalendarService(ICalendarService $icalendarService): void |
|
68
|
|
|
{ |
|
69
|
|
|
$this->icalendarService = $icalendarService; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
public function injectLocationRepository(LocationRepository $locationRepository): void |
|
73
|
|
|
{ |
|
74
|
|
|
$this->locationRepository = $locationRepository; |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
public function injectNotificationService(NotificationService $notificationService): void |
|
78
|
|
|
{ |
|
79
|
|
|
$this->notificationService = $notificationService; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
public function injectOrganisatorRepository(OrganisatorRepository $organisatorRepository): void |
|
83
|
|
|
{ |
|
84
|
|
|
$this->organisatorRepository = $organisatorRepository; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
public function injectSpeakerRepository(SpeakerRepository $speakerRepository): void |
|
88
|
|
|
{ |
|
89
|
|
|
$this->speakerRepository = $speakerRepository; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
public function injectPaymentService(PaymentService $paymentService): void |
|
93
|
|
|
{ |
|
94
|
|
|
$this->paymentService = $paymentService; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
public function injectRegistrationRepository(RegistrationRepository $registrationRepository): void |
|
98
|
|
|
{ |
|
99
|
|
|
$this->registrationRepository = $registrationRepository; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
public function injectRegistrationService(RegistrationService $registrationService): void |
|
103
|
|
|
{ |
|
104
|
|
|
$this->registrationService = $registrationService; |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
public function injectFieldRepository(FieldRepository $fieldRepository): void |
|
108
|
|
|
{ |
|
109
|
|
|
$this->fieldRepository = $fieldRepository; |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
/** |
|
113
|
|
|
* Public getter for extbase arguments. Can be used by extending extensions in e.g. event listeners to |
|
114
|
|
|
* retrieve the current controller arguments. |
|
115
|
|
|
*/ |
|
116
|
|
|
public function getControllerArguments(): Arguments |
|
117
|
|
|
{ |
|
118
|
|
|
return $this->arguments; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
/** |
|
122
|
|
|
* Public getter to retrieve extension settings. Can be used by extending extensions in e.g. event listeners to |
|
123
|
|
|
* retrieve the extension settings. |
|
124
|
|
|
*/ |
|
125
|
|
|
public function getSettings(): array |
|
126
|
|
|
{ |
|
127
|
|
|
return $this->settings ?? []; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* Returns an array with variables for the pagination. An array with pagination settings should be passed. |
|
132
|
|
|
* Applies default values if settings are not available: |
|
133
|
|
|
* - pagination disabled |
|
134
|
|
|
* - itemsPerPage = 10 |
|
135
|
|
|
* - maxNumPages = 10 |
|
136
|
|
|
*/ |
|
137
|
|
|
protected function getPagination(QueryResultInterface $events, array $settings): array |
|
138
|
|
|
{ |
|
139
|
|
|
$pagination = []; |
|
140
|
|
|
$currentPage = $this->request->hasArgument('currentPage') ? (int)$this->request->getArgument('currentPage') : 1; |
|
141
|
|
|
if (($settings['enablePagination'] ?? false) && (int)$settings['itemsPerPage'] > 0) { |
|
142
|
|
|
$paginator = new QueryResultPaginator($events, $currentPage, (int)($settings['itemsPerPage'] ?? 10)); |
|
143
|
|
|
$pagination = new NumberedPagination($paginator, (int)($settings['maxNumPages'] ?? 10)); |
|
144
|
|
|
$pagination = [ |
|
145
|
|
|
'paginator' => $paginator, |
|
146
|
|
|
'pagination' => $pagination, |
|
147
|
|
|
]; |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
return $pagination; |
|
151
|
|
|
} |
|
152
|
|
|
|
|
153
|
|
|
/** |
|
154
|
|
|
* Overwrites a given demand object by an propertyName => $propertyValue array |
|
155
|
|
|
*/ |
|
156
|
|
|
protected function overwriteEventDemandObject(EventDemand $demand, array $overwriteDemand): EventDemand |
|
157
|
|
|
{ |
|
158
|
|
|
foreach ($this->ignoredSettingsForOverwriteDemand as $property) { |
|
159
|
|
|
unset($overwriteDemand[$property]); |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
foreach ($overwriteDemand as $propertyName => $propertyValue) { |
|
163
|
|
|
if (in_array(strtolower($propertyName), $this->ignoredSettingsForOverwriteDemand, true)) { |
|
164
|
|
|
continue; |
|
165
|
|
|
} |
|
166
|
|
|
ObjectAccess::setProperty($demand, $propertyName, $propertyValue); |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
return $demand; |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
protected function getTypoScriptFrontendController(): ?TypoScriptFrontendController |
|
173
|
|
|
{ |
|
174
|
|
|
return $GLOBALS['TSFE'] ?? null; |
|
175
|
|
|
} |
|
176
|
|
|
} |
|
177
|
|
|
|