Completed
Pull Request — master (#352)
by
unknown
04:54
created

EventCommandHandler::getImportImagesClassName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
4
namespace CultuurNet\UDB3\Event;
5
6
use CultuurNet\UDB3\Event\Commands\AddImage;
7
use CultuurNet\UDB3\Event\Commands\AddLabel;
8
use CultuurNet\UDB3\Event\Commands\CreateEvent;
9
use CultuurNet\UDB3\Event\Commands\DeleteCurrentOrganizer;
10
use CultuurNet\UDB3\Event\Commands\DeleteEvent;
11
use CultuurNet\UDB3\Event\Commands\ImportImages;
12
use CultuurNet\UDB3\Event\Commands\ImportLabels;
13
use CultuurNet\UDB3\Event\Commands\RemoveLabel;
14
use CultuurNet\UDB3\Event\Commands\Moderation\Approve;
15
use CultuurNet\UDB3\Event\Commands\Moderation\FlagAsDuplicate;
16
use CultuurNet\UDB3\Event\Commands\Moderation\FlagAsInappropriate;
17
use CultuurNet\UDB3\Event\Commands\Moderation\Publish;
18
use CultuurNet\UDB3\Event\Commands\Moderation\Reject;
19
use CultuurNet\UDB3\Event\Commands\RemoveImage;
20
use CultuurNet\UDB3\Event\Commands\DeleteOrganizer;
21
use CultuurNet\UDB3\Event\Commands\DeleteTypicalAgeRange;
22
use CultuurNet\UDB3\Event\Commands\SelectMainImage;
23
use CultuurNet\UDB3\Event\Commands\UpdateFacilities;
24
use CultuurNet\UDB3\Event\Commands\UpdateTheme;
25
use CultuurNet\UDB3\Event\Commands\UpdateTitle;
26
use CultuurNet\UDB3\Event\Commands\UpdateAudience;
27
use CultuurNet\UDB3\Event\Commands\UpdateBookingInfo;
28
use CultuurNet\UDB3\Event\Commands\UpdateCalendar;
29
use CultuurNet\UDB3\Event\Commands\UpdateContactPoint;
30
use CultuurNet\UDB3\Event\Commands\UpdateDescription;
31
use CultuurNet\UDB3\Event\Commands\UpdateImage;
32
use CultuurNet\UDB3\Event\Commands\UpdateLocation;
33
use CultuurNet\UDB3\Event\Commands\UpdateMajorInfo;
34
use CultuurNet\UDB3\Event\Commands\UpdateOrganizer;
35
use CultuurNet\UDB3\Event\Commands\UpdatePriceInfo;
36
use CultuurNet\UDB3\Event\Commands\UpdateType;
37
use CultuurNet\UDB3\Event\Commands\UpdateTypicalAgeRange;
38
use CultuurNet\UDB3\Offer\OfferCommandHandler;
39
use Psr\Log\LoggerAwareInterface;
40
use Psr\Log\LoggerAwareTrait;
41
42
/**
43
 * Commandhandler for events
44
 */
45
class EventCommandHandler extends OfferCommandHandler implements LoggerAwareInterface
46
{
47
    use LoggerAwareTrait;
48
49
    /**
50
     * @param CreateEvent $command
51
     */
52 View Code Duplication
    protected function handleCreateEvent(CreateEvent $command)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
53
    {
54
        $event = Event::create(
55
            $command->getItemId(),
56
            $command->getMainLanguage(),
57
            $command->getTitle(),
58
            $command->getEventType(),
59
            $command->getLocation(),
60
            $command->getCalendar(),
61
            $command->getTheme(),
62
            $command->getPublicationDate()
63
        );
64
65
        $this->offerRepository->save($event);
66
    }
67
68
    /**
69
     * Handle an update the major info command.
70
     * @param UpdateMajorInfo $updateMajorInfo
71
     */
72 View Code Duplication
    public function handleUpdateMajorInfo(UpdateMajorInfo $updateMajorInfo)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

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.

Loading history...
73
    {
74
        /** @var Event $event */
75
        $event = $this->offerRepository->load($updateMajorInfo->getItemId());
76
77
        $event->updateMajorInfo(
78
            $updateMajorInfo->getTitle(),
79
            $updateMajorInfo->getEventType(),
80
            $updateMajorInfo->getLocation(),
81
            $updateMajorInfo->getCalendar(),
82
            $updateMajorInfo->getTheme()
83
        );
84
85
        $this->offerRepository->save($event);
86
87
    }
88
89
    /**
90
     * @param UpdateLocation $updateLocation
91
     */
92
    public function handleUpdateLocation(UpdateLocation $updateLocation)
93
    {
94
        /** @var Event $event */
95
        $event = $this->offerRepository->load($updateLocation->getItemId());
96
97
        $event->updateLocation($updateLocation->getLocationId());
98
99
        $this->offerRepository->save($event);
100
    }
101
102
    /**
103
     * @param UpdateAudience $updateAudience
104
     */
105
    public function handleUpdateAudience(UpdateAudience $updateAudience)
106
    {
107
        /** @var Event $event */
108
        $event = $this->offerRepository->load($updateAudience->getItemId());
109
110
        $event->updateAudience($updateAudience->getAudience());
111
112
        $this->offerRepository->save($event);
113
    }
114
115
    /**
116
     * @return string
117
     */
118
    protected function getAddLabelClassName()
119
    {
120
        return AddLabel::class;
121
    }
122
123
    /**
124
     * @return string
125
     */
126
    protected function getRemoveLabelClassName()
127
    {
128
        return RemoveLabel::class;
129
    }
130
131
    /**
132
     * @return string
133
     */
134
    protected function getImportLabelsClassName()
135
    {
136
        return ImportLabels::class;
137
    }
138
139
    /**
140
     * @return string
141
     */
142
    protected function getAddImageClassName()
143
    {
144
        return AddImage::class;
145
    }
146
147
    /**
148
     * @return string
149
     */
150
    protected function getUpdateImageClassName()
151
    {
152
        return UpdateImage::class;
153
    }
154
155
    /**
156
     * @return string
157
     */
158
    protected function getRemoveImageClassName()
159
    {
160
        return RemoveImage::class;
161
    }
162
163
    /**
164
     * @return string
165
     */
166
    protected function getSelectMainImageClassName()
167
    {
168
        return SelectMainImage::class;
169
    }
170
171
    /**
172
     * @return string
173
     */
174
    protected function getImportImagesClassName()
175
    {
176
        return ImportImages::class;
177
    }
178
179
    /**
180
     * @return string
181
     */
182
    protected function getUpdateTitleClassName()
183
    {
184
        return UpdateTitle::class;
185
    }
186
187
    /**
188
     * @return string
189
     */
190
    protected function getUpdateDescriptionClassName()
191
    {
192
        return UpdateDescription::class;
193
    }
194
195
    /**
196
     * @inheritdoc
197
     */
198
    protected function getUpdateCalendarClassName()
199
    {
200
        return UpdateCalendar::class;
201
    }
202
203
    /**
204
     * @return string
205
     */
206
    protected function getUpdateTypicalAgeRangeClassName()
207
    {
208
        return UpdateTypicalAgeRange::class;
209
    }
210
211
    /**
212
     * @return string
213
     */
214
    protected function getDeleteTypicalAgeRangeClassName()
215
    {
216
        return DeleteTypicalAgeRange::class;
217
    }
218
219
    /**
220
     * @return string
221
     */
222
    protected function getUpdateOrganizerClassName()
223
    {
224
        return UpdateOrganizer::class;
225
    }
226
227
    /**
228
     * @return string
229
     */
230
    protected function getDeleteOrganizerClassName()
231
    {
232
        return DeleteOrganizer::class;
233
    }
234
235
    /**
236
     * @return string
237
     */
238
    protected function getDeleteCurrentOrganizerClassName()
239
    {
240
        return DeleteCurrentOrganizer::class;
241
    }
242
243
    /**
244
     * @return string
245
     */
246
    protected function getUpdateContactPointClassName()
247
    {
248
        return UpdateContactPoint::class;
249
    }
250
251
    /**
252
     * @return string
253
     */
254
    protected function getUpdateBookingInfoClassName()
255
    {
256
        return UpdateBookingInfo::class;
257
    }
258
259
    /**
260
     * @return string
261
     */
262
    protected function getUpdatePriceInfoClassName()
263
    {
264
        return UpdatePriceInfo::class;
265
    }
266
267
    /**
268
     * @return string
269
     */
270
    protected function getDeleteOfferClassName()
271
    {
272
        return DeleteEvent::class;
273
    }
274
275
    protected function getPublishClassName()
276
    {
277
        return Publish::class;
278
    }
279
280
    protected function getApproveClassName()
281
    {
282
        return Approve::class;
283
    }
284
285
    protected function getRejectClassName()
286
    {
287
        return Reject::class;
288
    }
289
290
    protected function getFlagAsDuplicateClassName()
291
    {
292
        return FlagAsDuplicate::class;
293
    }
294
295
    protected function getFlagAsInappropriateClassName()
296
    {
297
        return FlagAsInappropriate::class;
298
    }
299
300
    /**
301
     * @inheritdoc
302
     */
303
    protected function getUpdateTypeClassName()
304
    {
305
        return UpdateType::class;
306
    }
307
308
    /**
309
     * @inheritdoc
310
     */
311
    protected function getUpdateThemeClassName()
312
    {
313
        return UpdateTheme::class;
314
    }
315
316
    /**
317
     * @inheritdoc
318
     */
319
    protected function getUpdateFacilitiesClassName()
320
    {
321
        return UpdateFacilities::class;
322
    }
323
}
324