1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace CultuurNet\UDB3\Place; |
4
|
|
|
|
5
|
|
|
use CultuurNet\UDB3\Offer\OfferCommandHandler; |
6
|
|
|
use CultuurNet\UDB3\Place\Commands\AddImage; |
7
|
|
|
use CultuurNet\UDB3\Place\Commands\Moderation\Approve; |
8
|
|
|
use CultuurNet\UDB3\Place\Commands\Moderation\FlagAsDuplicate; |
9
|
|
|
use CultuurNet\UDB3\Place\Commands\Moderation\FlagAsInappropriate; |
10
|
|
|
use CultuurNet\UDB3\Place\Commands\Moderation\Publish; |
11
|
|
|
use CultuurNet\UDB3\Place\Commands\Moderation\Reject; |
12
|
|
|
use CultuurNet\UDB3\Place\Commands\RemoveImage; |
13
|
|
|
use CultuurNet\UDB3\Place\Commands\AddLabel; |
14
|
|
|
use CultuurNet\UDB3\Place\Commands\RemoveLabel; |
15
|
|
|
use CultuurNet\UDB3\Place\Commands\DeleteOrganizer; |
16
|
|
|
use CultuurNet\UDB3\Place\Commands\DeletePlace; |
17
|
|
|
use CultuurNet\UDB3\Place\Commands\DeleteTypicalAgeRange; |
18
|
|
|
use CultuurNet\UDB3\Place\Commands\SelectMainImage; |
19
|
|
|
use CultuurNet\UDB3\Place\Commands\UpdateAddress; |
20
|
|
|
use CultuurNet\UDB3\Place\Commands\UpdateBookingInfo; |
21
|
|
|
use CultuurNet\UDB3\Place\Commands\UpdateCalendar; |
22
|
|
|
use CultuurNet\UDB3\Place\Commands\UpdateContactPoint; |
23
|
|
|
use CultuurNet\UDB3\Place\Commands\UpdateDescription; |
24
|
|
|
use CultuurNet\UDB3\Place\Commands\UpdateFacilities; |
25
|
|
|
use CultuurNet\UDB3\Place\Commands\UpdateImage; |
26
|
|
|
use CultuurNet\UDB3\Place\Commands\UpdateMajorInfo; |
27
|
|
|
use CultuurNet\UDB3\Place\Commands\UpdateOrganizer; |
28
|
|
|
use CultuurNet\UDB3\Place\Commands\UpdatePriceInfo; |
29
|
|
|
use CultuurNet\UDB3\Place\Commands\UpdateTitle; |
30
|
|
|
use CultuurNet\UDB3\Place\Commands\UpdateTypicalAgeRange; |
31
|
|
|
use Psr\Log\LoggerAwareInterface; |
32
|
|
|
use Psr\Log\LoggerAwareTrait; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Commandhandler for places. |
36
|
|
|
*/ |
37
|
|
|
class CommandHandler extends OfferCommandHandler implements LoggerAwareInterface |
38
|
|
|
{ |
39
|
|
|
use LoggerAwareTrait; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* @return string |
43
|
|
|
*/ |
44
|
|
|
protected function getAddLabelClassName() |
45
|
|
|
{ |
46
|
|
|
return AddLabel::class; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @return string |
51
|
|
|
*/ |
52
|
|
|
protected function getRemoveLabelClassName() |
53
|
|
|
{ |
54
|
|
|
return RemoveLabel::class; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @return string |
59
|
|
|
*/ |
60
|
|
|
protected function getAddImageClassName() |
61
|
|
|
{ |
62
|
|
|
return AddImage::class; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* @return string |
67
|
|
|
*/ |
68
|
|
|
protected function getUpdateImageClassName() |
69
|
|
|
{ |
70
|
|
|
return UpdateImage::class; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @return string |
75
|
|
|
*/ |
76
|
|
|
protected function getRemoveImageClassName() |
77
|
|
|
{ |
78
|
|
|
return RemoveImage::class; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @return string |
83
|
|
|
*/ |
84
|
|
|
protected function getSelectMainImageClassName() |
85
|
|
|
{ |
86
|
|
|
return SelectMainImage::class; |
87
|
|
|
} |
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @return string |
91
|
|
|
*/ |
92
|
|
|
protected function getUpdateTitleClassName() |
93
|
|
|
{ |
94
|
|
|
return UpdateTitle::class; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @return string |
99
|
|
|
*/ |
100
|
|
|
protected function getUpdateDescriptionClassName() |
101
|
|
|
{ |
102
|
|
|
return UpdateDescription::class; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* @inheritdoc |
107
|
|
|
*/ |
108
|
|
|
protected function getUpdateCalendarClassName() |
109
|
|
|
{ |
110
|
|
|
return UpdateCalendar::class; |
111
|
|
|
} |
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @return string |
115
|
|
|
*/ |
116
|
|
|
protected function getUpdateTypicalAgeRangeClassName() |
117
|
|
|
{ |
118
|
|
|
return UpdateTypicalAgeRange::class; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @return string |
123
|
|
|
*/ |
124
|
|
|
protected function getDeleteTypicalAgeRangeClassName() |
125
|
|
|
{ |
126
|
|
|
return DeleteTypicalAgeRange::class; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @return string |
131
|
|
|
*/ |
132
|
|
|
protected function getUpdateOrganizerClassName() |
133
|
|
|
{ |
134
|
|
|
return UpdateOrganizer::class; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @return string |
139
|
|
|
*/ |
140
|
|
|
protected function getDeleteOrganizerClassName() |
141
|
|
|
{ |
142
|
|
|
return DeleteOrganizer::class; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* @return string |
147
|
|
|
*/ |
148
|
|
|
protected function getUpdateContactPointClassName() |
149
|
|
|
{ |
150
|
|
|
return UpdateContactPoint::class; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* @return string |
155
|
|
|
*/ |
156
|
|
|
protected function getUpdateBookingInfoClassName() |
157
|
|
|
{ |
158
|
|
|
return UpdateBookingInfo::class; |
159
|
|
|
} |
160
|
|
|
|
161
|
|
|
/** |
162
|
|
|
* @return string |
163
|
|
|
*/ |
164
|
|
|
protected function getUpdatePriceInfoClassName() |
165
|
|
|
{ |
166
|
|
|
return UpdatePriceInfo::class; |
167
|
|
|
} |
168
|
|
|
|
169
|
|
|
/** |
170
|
|
|
* @return string |
171
|
|
|
*/ |
172
|
|
|
protected function getDeleteOfferClassName() |
173
|
|
|
{ |
174
|
|
|
return DeletePlace::class; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
protected function getPublishClassName() |
178
|
|
|
{ |
179
|
|
|
return Publish::class; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
protected function getApproveClassName() |
183
|
|
|
{ |
184
|
|
|
return Approve::class; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
protected function getRejectClassName() |
188
|
|
|
{ |
189
|
|
|
return Reject::class; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
protected function getFlagAsDuplicateClassName() |
193
|
|
|
{ |
194
|
|
|
return FlagAsDuplicate::class; |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
protected function getFlagAsInappropriateClassName() |
198
|
|
|
{ |
199
|
|
|
return FlagAsInappropriate::class; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
/** |
203
|
|
|
* @param UpdateAddress $updateAddress |
204
|
|
|
*/ |
205
|
|
|
protected function handleUpdateAddress(UpdateAddress $updateAddress) |
206
|
|
|
{ |
207
|
|
|
/* @var Place $place */ |
208
|
|
|
$place = $this->offerRepository->load($updateAddress->getItemId()); |
209
|
|
|
$place->updateAddress($updateAddress->getAddress(), $updateAddress->getLanguage()); |
210
|
|
|
$this->offerRepository->save($place); |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* Handle the update of facilities for a place. |
215
|
|
|
* @param UpdateFacilities $updateFacilities |
216
|
|
|
*/ |
217
|
|
|
public function handleUpdateFacilities(UpdateFacilities $updateFacilities) |
218
|
|
|
{ |
219
|
|
|
|
220
|
|
|
/** @var Place $place */ |
221
|
|
|
$place = $this->offerRepository->load($updateFacilities->getItemId()); |
222
|
|
|
|
223
|
|
|
$place->updateFacilities( |
224
|
|
|
$updateFacilities->getFacilities() |
225
|
|
|
); |
226
|
|
|
|
227
|
|
|
$this->offerRepository->save($place); |
228
|
|
|
} |
229
|
|
|
|
230
|
|
|
/** |
231
|
|
|
* Handle an update the major info command. |
232
|
|
|
* @param UpdateMajorInfo $updateMajorInfo |
233
|
|
|
*/ |
234
|
|
View Code Duplication |
public function handleUpdateMajorInfo(UpdateMajorInfo $updateMajorInfo) |
|
|
|
|
235
|
|
|
{ |
236
|
|
|
|
237
|
|
|
/** @var Place $place */ |
238
|
|
|
$place = $this->offerRepository->load($updateMajorInfo->getItemId()); |
239
|
|
|
|
240
|
|
|
$place->updateMajorInfo( |
241
|
|
|
$updateMajorInfo->getTitle(), |
242
|
|
|
$updateMajorInfo->getEventType(), |
243
|
|
|
$updateMajorInfo->getAddress(), |
244
|
|
|
$updateMajorInfo->getCalendar(), |
245
|
|
|
$updateMajorInfo->getTheme() |
246
|
|
|
); |
247
|
|
|
|
248
|
|
|
$this->offerRepository->save($place); |
249
|
|
|
|
250
|
|
|
} |
251
|
|
|
} |
252
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.