Completed
Pull Request — master (#350)
by
unknown
05:43
created

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