Completed
Pull Request — master (#345)
by
unknown
05:39
created

CommandHandler::getDeleteOrganizerClassName()   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 Broadway\Repository\AggregateNotFoundException;
6
use CultuurNet\UDB3\Language;
7
use CultuurNet\UDB3\Offer\OfferCommandHandler;
8
use CultuurNet\UDB3\Place\Commands\AddImage;
9
use CultuurNet\UDB3\Place\Commands\CreatePlace;
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 getAddImageClassName()
66
    {
67
        return AddImage::class;
68
    }
69
70
    /**
71
     * @return string
72
     */
73
    protected function getUpdateImageClassName()
74
    {
75
        return UpdateImage::class;
76
    }
77
78
    /**
79
     * @return string
80
     */
81
    protected function getRemoveImageClassName()
82
    {
83
        return RemoveImage::class;
84
    }
85
86
    /**
87
     * @return string
88
     */
89
    protected function getSelectMainImageClassName()
90
    {
91
        return SelectMainImage::class;
92
    }
93
94
    /**
95
     * @return string
96
     */
97
    protected function getUpdateTitleClassName()
98
    {
99
        return UpdateTitle::class;
100
    }
101
102
    /**
103
     * @return string
104
     */
105
    protected function getUpdateDescriptionClassName()
106
    {
107
        return UpdateDescription::class;
108
    }
109
110
    /**
111
     * @inheritdoc
112
     */
113
    protected function getUpdateCalendarClassName()
114
    {
115
        return UpdateCalendar::class;
116
    }
117
118
    /**
119
     * @return string
120
     */
121
    protected function getUpdateTypicalAgeRangeClassName()
122
    {
123
        return UpdateTypicalAgeRange::class;
124
    }
125
126
    /**
127
     * @return string
128
     */
129
    protected function getDeleteTypicalAgeRangeClassName()
130
    {
131
        return DeleteTypicalAgeRange::class;
132
    }
133
134
    /**
135
     * @return string
136
     */
137
    protected function getUpdateOrganizerClassName()
138
    {
139
        return UpdateOrganizer::class;
140
    }
141
142
    /**
143
     * @return string
144
     */
145
    protected function getDeleteOrganizerClassName()
146
    {
147
        return DeleteOrganizer::class;
148
    }
149
150
    /**
151
     * @return string
152
     */
153
    protected function getUpdateContactPointClassName()
154
    {
155
        return UpdateContactPoint::class;
156
    }
157
158
    /**
159
     * @return string
160
     */
161
    protected function getUpdateBookingInfoClassName()
162
    {
163
        return UpdateBookingInfo::class;
164
    }
165
166
    /**
167
     * @return string
168
     */
169
    protected function getUpdatePriceInfoClassName()
170
    {
171
        return UpdatePriceInfo::class;
172
    }
173
174
    /**
175
     * @return string
176
     */
177
    protected function getDeleteOfferClassName()
178
    {
179
        return DeletePlace::class;
180
    }
181
182
    protected function getPublishClassName()
183
    {
184
        return Publish::class;
185
    }
186
187
    protected function getApproveClassName()
188
    {
189
        return Approve::class;
190
    }
191
192
    protected function getRejectClassName()
193
    {
194
        return Reject::class;
195
    }
196
197
    protected function getFlagAsDuplicateClassName()
198
    {
199
        return FlagAsDuplicate::class;
200
    }
201
202
    protected function getFlagAsInappropriateClassName()
203
    {
204
        return FlagAsInappropriate::class;
205
    }
206
207
    /**
208
     * @param CreatePlace $command
209
     */
210 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...
211
    {
212
        $place = Place::createPlace(
213
            $command->getItemId(),
214
            $command->getMainLanguage(),
215
            $command->getTitle(),
216
            $command->getEventType(),
217
            $command->getAddress(),
218
            $command->getCalendar(),
219
            $command->getTheme(),
220
            $command->getPublicationDate()
221
        );
222
223
        $this->offerRepository->save($place);
224
    }
225
226
    /**
227
     * @param UpdateAddress $updateAddress
228
     */
229
    protected function handleUpdateAddress(UpdateAddress $updateAddress)
230
    {
231
        /* @var Place $place */
232
        $place = $this->offerRepository->load($updateAddress->getItemId());
233
        $place->updateAddress($updateAddress->getAddress(), $updateAddress->getLanguage());
234
        $this->offerRepository->save($place);
235
    }
236
237
    /**
238
     * Handle an update the major info command.
239
     * @param UpdateMajorInfo $updateMajorInfo
240
     */
241 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...
242
    {
243
244
        /** @var Place $place */
245
        $place = $this->offerRepository->load($updateMajorInfo->getItemId());
246
247
        $place->updateMajorInfo(
248
            $updateMajorInfo->getTitle(),
249
            $updateMajorInfo->getEventType(),
250
            $updateMajorInfo->getAddress(),
251
            $updateMajorInfo->getCalendar(),
252
            $updateMajorInfo->getTheme()
253
        );
254
255
        $this->offerRepository->save($place);
256
257
    }
258
259
    protected function getUpdateTypeClassName()
260
    {
261
        return UpdateType::class;
262
    }
263
264
    protected function getUpdateThemeClassName()
265
    {
266
        return UpdateTheme::class;
267
    }
268
269
    /**
270
     * @inheritdoc
271
     */
272
    protected function getUpdateFacilitiesClassName()
273
    {
274
        return UpdateFacilities::class;
275
    }
276
}
277