Completed
Pull Request — master (#345)
by
unknown
25:32 queued 12:36
created

EventCommandHandler::handleCreateEvent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 11

Duplication

Lines 15
Ratio 100 %

Importance

Changes 0
Metric Value
dl 15
loc 15
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 11
nc 1
nop 1
1
<?php
2
3
4
namespace CultuurNet\UDB3\Event;
5
6
use Broadway\Repository\AggregateNotFoundException;
7
use CultuurNet\UDB3\Event\Commands\AddImage;
8
use CultuurNet\UDB3\Event\Commands\AddLabel;
9
use CultuurNet\UDB3\Event\Commands\CreateEvent;
10
use CultuurNet\UDB3\Event\Commands\DeleteEvent;
11
use CultuurNet\UDB3\Event\Commands\RemoveLabel;
12
use CultuurNet\UDB3\Event\Commands\Moderation\Approve;
13
use CultuurNet\UDB3\Event\Commands\Moderation\FlagAsDuplicate;
14
use CultuurNet\UDB3\Event\Commands\Moderation\FlagAsInappropriate;
15
use CultuurNet\UDB3\Event\Commands\Moderation\Publish;
16
use CultuurNet\UDB3\Event\Commands\Moderation\Reject;
17
use CultuurNet\UDB3\Event\Commands\RemoveImage;
18
use CultuurNet\UDB3\Event\Commands\DeleteOrganizer;
19
use CultuurNet\UDB3\Event\Commands\DeleteTypicalAgeRange;
20
use CultuurNet\UDB3\Event\Commands\SelectMainImage;
21
use CultuurNet\UDB3\Event\Commands\UpdateFacilities;
22
use CultuurNet\UDB3\Event\Commands\UpdateTheme;
23
use CultuurNet\UDB3\Event\Commands\UpdateTitle;
24
use CultuurNet\UDB3\Event\Commands\UpdateAudience;
25
use CultuurNet\UDB3\Event\Commands\UpdateBookingInfo;
26
use CultuurNet\UDB3\Event\Commands\UpdateCalendar;
27
use CultuurNet\UDB3\Event\Commands\UpdateContactPoint;
28
use CultuurNet\UDB3\Event\Commands\UpdateDescription;
29
use CultuurNet\UDB3\Event\Commands\UpdateImage;
30
use CultuurNet\UDB3\Event\Commands\UpdateLocation;
31
use CultuurNet\UDB3\Event\Commands\UpdateMajorInfo;
32
use CultuurNet\UDB3\Event\Commands\UpdateOrganizer;
33
use CultuurNet\UDB3\Event\Commands\UpdatePriceInfo;
34
use CultuurNet\UDB3\Event\Commands\UpdateType;
35
use CultuurNet\UDB3\Event\Commands\UpdateTypicalAgeRange;
36
use CultuurNet\UDB3\Language;
37
use CultuurNet\UDB3\Location\LocationId;
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 getAddImageClassName()
135
    {
136
        return AddImage::class;
137
    }
138
139
    /**
140
     * @return string
141
     */
142
    protected function getUpdateImageClassName()
143
    {
144
        return UpdateImage::class;
145
    }
146
147
    /**
148
     * @return string
149
     */
150
    protected function getRemoveImageClassName()
151
    {
152
        return RemoveImage::class;
153
    }
154
155
    /**
156
     * @return string
157
     */
158
    protected function getSelectMainImageClassName()
159
    {
160
        return SelectMainImage::class;
161
    }
162
163
    /**
164
     * @return string
165
     */
166
    protected function getUpdateTitleClassName()
167
    {
168
        return UpdateTitle::class;
169
    }
170
171
    /**
172
     * @return string
173
     */
174
    protected function getUpdateDescriptionClassName()
175
    {
176
        return UpdateDescription::class;
177
    }
178
179
    /**
180
     * @inheritdoc
181
     */
182
    protected function getUpdateCalendarClassName()
183
    {
184
        return UpdateCalendar::class;
185
    }
186
187
    /**
188
     * @return string
189
     */
190
    protected function getUpdateTypicalAgeRangeClassName()
191
    {
192
        return UpdateTypicalAgeRange::class;
193
    }
194
195
    /**
196
     * @return string
197
     */
198
    protected function getDeleteTypicalAgeRangeClassName()
199
    {
200
        return DeleteTypicalAgeRange::class;
201
    }
202
203
    /**
204
     * @return string
205
     */
206
    protected function getUpdateOrganizerClassName()
207
    {
208
        return UpdateOrganizer::class;
209
    }
210
211
    /**
212
     * @return string
213
     */
214
    protected function getDeleteOrganizerClassName()
215
    {
216
        return DeleteOrganizer::class;
217
    }
218
219
    /**
220
     * @return string
221
     */
222
    protected function getUpdateContactPointClassName()
223
    {
224
        return UpdateContactPoint::class;
225
    }
226
227
    /**
228
     * @return string
229
     */
230
    protected function getUpdateBookingInfoClassName()
231
    {
232
        return UpdateBookingInfo::class;
233
    }
234
235
    /**
236
     * @return string
237
     */
238
    protected function getUpdatePriceInfoClassName()
239
    {
240
        return UpdatePriceInfo::class;
241
    }
242
243
    /**
244
     * @return string
245
     */
246
    protected function getDeleteOfferClassName()
247
    {
248
        return DeleteEvent::class;
249
    }
250
251
    protected function getPublishClassName()
252
    {
253
        return Publish::class;
254
    }
255
256
    protected function getApproveClassName()
257
    {
258
        return Approve::class;
259
    }
260
261
    protected function getRejectClassName()
262
    {
263
        return Reject::class;
264
    }
265
266
    protected function getFlagAsDuplicateClassName()
267
    {
268
        return FlagAsDuplicate::class;
269
    }
270
271
    protected function getFlagAsInappropriateClassName()
272
    {
273
        return FlagAsInappropriate::class;
274
    }
275
276
    /**
277
     * @inheritdoc
278
     */
279
    protected function getUpdateTypeClassName()
280
    {
281
        return UpdateType::class;
282
    }
283
284
    /**
285
     * @inheritdoc
286
     */
287
    protected function getUpdateThemeClassName()
288
    {
289
        return UpdateTheme::class;
290
    }
291
292
    /**
293
     * @inheritdoc
294
     */
295
    protected function getUpdateFacilitiesClassName()
296
    {
297
        return UpdateFacilities::class;
298
    }
299
}
300