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

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