Completed
Pull Request — master (#349)
by Luc
05:05
created

EventCommandHandler::getImportLabelsClassName()   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\ImportLabels;
12
use CultuurNet\UDB3\Event\Commands\RemoveLabel;
13
use CultuurNet\UDB3\Event\Commands\Moderation\Approve;
14
use CultuurNet\UDB3\Event\Commands\Moderation\FlagAsDuplicate;
15
use CultuurNet\UDB3\Event\Commands\Moderation\FlagAsInappropriate;
16
use CultuurNet\UDB3\Event\Commands\Moderation\Publish;
17
use CultuurNet\UDB3\Event\Commands\Moderation\Reject;
18
use CultuurNet\UDB3\Event\Commands\RemoveImage;
19
use CultuurNet\UDB3\Event\Commands\DeleteOrganizer;
20
use CultuurNet\UDB3\Event\Commands\DeleteTypicalAgeRange;
21
use CultuurNet\UDB3\Event\Commands\SelectMainImage;
22
use CultuurNet\UDB3\Event\Commands\UpdateFacilities;
23
use CultuurNet\UDB3\Event\Commands\UpdateTheme;
24
use CultuurNet\UDB3\Event\Commands\UpdateTitle;
25
use CultuurNet\UDB3\Event\Commands\UpdateAudience;
26
use CultuurNet\UDB3\Event\Commands\UpdateBookingInfo;
27
use CultuurNet\UDB3\Event\Commands\UpdateCalendar;
28
use CultuurNet\UDB3\Event\Commands\UpdateContactPoint;
29
use CultuurNet\UDB3\Event\Commands\UpdateDescription;
30
use CultuurNet\UDB3\Event\Commands\UpdateImage;
31
use CultuurNet\UDB3\Event\Commands\UpdateLocation;
32
use CultuurNet\UDB3\Event\Commands\UpdateMajorInfo;
33
use CultuurNet\UDB3\Event\Commands\UpdateOrganizer;
34
use CultuurNet\UDB3\Event\Commands\UpdatePriceInfo;
35
use CultuurNet\UDB3\Event\Commands\UpdateType;
36
use CultuurNet\UDB3\Event\Commands\UpdateTypicalAgeRange;
37
use CultuurNet\UDB3\Offer\OfferCommandHandler;
38
use Psr\Log\LoggerAwareInterface;
39
use Psr\Log\LoggerAwareTrait;
40
41
/**
42
 * Commandhandler for events
43
 */
44
class EventCommandHandler extends OfferCommandHandler implements LoggerAwareInterface
45
{
46
    use LoggerAwareTrait;
47
48
    /**
49
     * @param CreateEvent $command
50
     */
51 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...
52
    {
53
        $event = Event::create(
54
            $command->getItemId(),
55
            $command->getMainLanguage(),
56
            $command->getTitle(),
57
            $command->getEventType(),
58
            $command->getLocation(),
59
            $command->getCalendar(),
60
            $command->getTheme(),
61
            $command->getPublicationDate()
62
        );
63
64
        $this->offerRepository->save($event);
65
    }
66
67
    /**
68
     * Handle an update the major info command.
69
     * @param UpdateMajorInfo $updateMajorInfo
70
     */
71 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...
72
    {
73
        /** @var Event $event */
74
        $event = $this->offerRepository->load($updateMajorInfo->getItemId());
75
76
        $event->updateMajorInfo(
77
            $updateMajorInfo->getTitle(),
78
            $updateMajorInfo->getEventType(),
79
            $updateMajorInfo->getLocation(),
80
            $updateMajorInfo->getCalendar(),
81
            $updateMajorInfo->getTheme()
82
        );
83
84
        $this->offerRepository->save($event);
85
86
    }
87
88
    /**
89
     * @param UpdateLocation $updateLocation
90
     */
91
    public function handleUpdateLocation(UpdateLocation $updateLocation)
92
    {
93
        /** @var Event $event */
94
        $event = $this->offerRepository->load($updateLocation->getItemId());
95
96
        $event->updateLocation($updateLocation->getLocationId());
97
98
        $this->offerRepository->save($event);
99
    }
100
101
    /**
102
     * @param UpdateAudience $updateAudience
103
     */
104
    public function handleUpdateAudience(UpdateAudience $updateAudience)
105
    {
106
        /** @var Event $event */
107
        $event = $this->offerRepository->load($updateAudience->getItemId());
108
109
        $event->updateAudience($updateAudience->getAudience());
110
111
        $this->offerRepository->save($event);
112
    }
113
114
    /**
115
     * @return string
116
     */
117
    protected function getAddLabelClassName()
118
    {
119
        return AddLabel::class;
120
    }
121
122
    /**
123
     * @return string
124
     */
125
    protected function getRemoveLabelClassName()
126
    {
127
        return RemoveLabel::class;
128
    }
129
130
    /**
131
     * @return string
132
     */
133
    protected function getImportLabelsClassName()
134
    {
135
        return ImportLabels::class;
136
    }
137
138
    /**
139
     * @return string
140
     */
141
    protected function getAddImageClassName()
142
    {
143
        return AddImage::class;
144
    }
145
146
    /**
147
     * @return string
148
     */
149
    protected function getUpdateImageClassName()
150
    {
151
        return UpdateImage::class;
152
    }
153
154
    /**
155
     * @return string
156
     */
157
    protected function getRemoveImageClassName()
158
    {
159
        return RemoveImage::class;
160
    }
161
162
    /**
163
     * @return string
164
     */
165
    protected function getSelectMainImageClassName()
166
    {
167
        return SelectMainImage::class;
168
    }
169
170
    /**
171
     * @return string
172
     */
173
    protected function getUpdateTitleClassName()
174
    {
175
        return UpdateTitle::class;
176
    }
177
178
    /**
179
     * @return string
180
     */
181
    protected function getUpdateDescriptionClassName()
182
    {
183
        return UpdateDescription::class;
184
    }
185
186
    /**
187
     * @inheritdoc
188
     */
189
    protected function getUpdateCalendarClassName()
190
    {
191
        return UpdateCalendar::class;
192
    }
193
194
    /**
195
     * @return string
196
     */
197
    protected function getUpdateTypicalAgeRangeClassName()
198
    {
199
        return UpdateTypicalAgeRange::class;
200
    }
201
202
    /**
203
     * @return string
204
     */
205
    protected function getDeleteTypicalAgeRangeClassName()
206
    {
207
        return DeleteTypicalAgeRange::class;
208
    }
209
210
    /**
211
     * @return string
212
     */
213
    protected function getUpdateOrganizerClassName()
214
    {
215
        return UpdateOrganizer::class;
216
    }
217
218
    /**
219
     * @return string
220
     */
221
    protected function getDeleteOrganizerClassName()
222
    {
223
        return DeleteOrganizer::class;
224
    }
225
226
    /**
227
     * @return string
228
     */
229
    protected function getDeleteCurrentOrganizerClassName()
230
    {
231
        return DeleteCurrentOrganizer::class;
232
    }
233
234
    /**
235
     * @return string
236
     */
237
    protected function getUpdateContactPointClassName()
238
    {
239
        return UpdateContactPoint::class;
240
    }
241
242
    /**
243
     * @return string
244
     */
245
    protected function getUpdateBookingInfoClassName()
246
    {
247
        return UpdateBookingInfo::class;
248
    }
249
250
    /**
251
     * @return string
252
     */
253
    protected function getUpdatePriceInfoClassName()
254
    {
255
        return UpdatePriceInfo::class;
256
    }
257
258
    /**
259
     * @return string
260
     */
261
    protected function getDeleteOfferClassName()
262
    {
263
        return DeleteEvent::class;
264
    }
265
266
    protected function getPublishClassName()
267
    {
268
        return Publish::class;
269
    }
270
271
    protected function getApproveClassName()
272
    {
273
        return Approve::class;
274
    }
275
276
    protected function getRejectClassName()
277
    {
278
        return Reject::class;
279
    }
280
281
    protected function getFlagAsDuplicateClassName()
282
    {
283
        return FlagAsDuplicate::class;
284
    }
285
286
    protected function getFlagAsInappropriateClassName()
287
    {
288
        return FlagAsInappropriate::class;
289
    }
290
291
    /**
292
     * @inheritdoc
293
     */
294
    protected function getUpdateTypeClassName()
295
    {
296
        return UpdateType::class;
297
    }
298
299
    /**
300
     * @inheritdoc
301
     */
302
    protected function getUpdateThemeClassName()
303
    {
304
        return UpdateTheme::class;
305
    }
306
307
    /**
308
     * @inheritdoc
309
     */
310
    protected function getUpdateFacilitiesClassName()
311
    {
312
        return UpdateFacilities::class;
313
    }
314
}
315