Completed
Pull Request — master (#314)
by Luc
04:56
created

CommandHandler::getTranslateDescriptionClassName()   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\Moderation\Approve;
8
use CultuurNet\UDB3\Place\Commands\Moderation\FlagAsDuplicate;
9
use CultuurNet\UDB3\Place\Commands\Moderation\FlagAsInappropriate;
10
use CultuurNet\UDB3\Place\Commands\Moderation\Publish;
11
use CultuurNet\UDB3\Place\Commands\Moderation\Reject;
12
use CultuurNet\UDB3\Place\Commands\RemoveImage;
13
use CultuurNet\UDB3\Place\Commands\AddLabel;
14
use CultuurNet\UDB3\Place\Commands\RemoveLabel;
15
use CultuurNet\UDB3\Place\Commands\DeleteOrganizer;
16
use CultuurNet\UDB3\Place\Commands\DeletePlace;
17
use CultuurNet\UDB3\Place\Commands\DeleteTypicalAgeRange;
18
use CultuurNet\UDB3\Place\Commands\SelectMainImage;
19
use CultuurNet\UDB3\Place\Commands\TranslateTitle;
20
use CultuurNet\UDB3\Place\Commands\UpdateAddress;
21
use CultuurNet\UDB3\Place\Commands\UpdateBookingInfo;
22
use CultuurNet\UDB3\Place\Commands\UpdateContactPoint;
23
use CultuurNet\UDB3\Place\Commands\UpdateDescription;
24
use CultuurNet\UDB3\Place\Commands\UpdateFacilities;
25
use CultuurNet\UDB3\Place\Commands\UpdateImage;
26
use CultuurNet\UDB3\Place\Commands\UpdateMajorInfo;
27
use CultuurNet\UDB3\Place\Commands\UpdateOrganizer;
28
use CultuurNet\UDB3\Place\Commands\UpdatePriceInfo;
29
use CultuurNet\UDB3\Place\Commands\UpdateTypicalAgeRange;
30
use Psr\Log\LoggerAwareInterface;
31
use Psr\Log\LoggerAwareTrait;
32
33
/**
34
 * Commandhandler for places.
35
 */
36
class CommandHandler extends OfferCommandHandler implements LoggerAwareInterface
37
{
38
    use LoggerAwareTrait;
39
40
    /**
41
     * @return string
42
     */
43
    protected function getAddLabelClassName()
44
    {
45
        return AddLabel::class;
46
    }
47
48
    /**
49
     * @return string
50
     */
51
    protected function getRemoveLabelClassName()
52
    {
53
        return RemoveLabel::class;
54
    }
55
56
    /**
57
     * @return string
58
     */
59
    protected function getAddImageClassName()
60
    {
61
        return AddImage::class;
62
    }
63
64
    /**
65
     * @return string
66
     */
67
    protected function getUpdateImageClassName()
68
    {
69
        return UpdateImage::class;
70
    }
71
72
    /**
73
     * @return string
74
     */
75
    protected function getRemoveImageClassName()
76
    {
77
        return RemoveImage::class;
78
    }
79
80
    /**
81
     * @return string
82
     */
83
    protected function getSelectMainImageClassName()
84
    {
85
        return SelectMainImage::class;
86
    }
87
88
    /**
89
     * @return string
90
     */
91
    protected function getTranslateTitleClassName()
92
    {
93
        return TranslateTitle::class;
94
    }
95
96
    /**
97
     * @return string
98
     */
99
    protected function getUpdateDescriptionClassName()
100
    {
101
        return UpdateDescription::class;
102
    }
103
104
    /**
105
     * @return string
106
     */
107
    protected function getUpdateTypicalAgeRangeClassName()
108
    {
109
        return UpdateTypicalAgeRange::class;
110
    }
111
112
    /**
113
     * @return string
114
     */
115
    protected function getDeleteTypicalAgeRangeClassName()
116
    {
117
        return DeleteTypicalAgeRange::class;
118
    }
119
120
    /**
121
     * @return string
122
     */
123
    protected function getUpdateOrganizerClassName()
124
    {
125
        return UpdateOrganizer::class;
126
    }
127
128
    /**
129
     * @return string
130
     */
131
    protected function getDeleteOrganizerClassName()
132
    {
133
        return DeleteOrganizer::class;
134
    }
135
136
    /**
137
     * @return string
138
     */
139
    protected function getUpdateContactPointClassName()
140
    {
141
        return UpdateContactPoint::class;
142
    }
143
144
    /**
145
     * @return string
146
     */
147
    protected function getUpdateBookingInfoClassName()
148
    {
149
        return UpdateBookingInfo::class;
150
    }
151
152
    /**
153
     * @return string
154
     */
155
    protected function getUpdatePriceInfoClassName()
156
    {
157
        return UpdatePriceInfo::class;
158
    }
159
160
    /**
161
     * @return string
162
     */
163
    protected function getDeleteOfferClassName()
164
    {
165
        return DeletePlace::class;
166
    }
167
168
    protected function getPublishClassName()
169
    {
170
        return Publish::class;
171
    }
172
173
    protected function getApproveClassName()
174
    {
175
        return Approve::class;
176
    }
177
178
    protected function getRejectClassName()
179
    {
180
        return Reject::class;
181
    }
182
183
    protected function getFlagAsDuplicateClassName()
184
    {
185
        return FlagAsDuplicate::class;
186
    }
187
188
    protected function getFlagAsInappropriateClassName()
189
    {
190
        return FlagAsInappropriate::class;
191
    }
192
193
    /**
194
     * @param UpdateAddress $updateAddress
195
     */
196
    protected function handleUpdateAddress(UpdateAddress $updateAddress)
197
    {
198
        /* @var Place $place */
199
        $place = $this->offerRepository->load($updateAddress->getItemId());
200
        $place->updateAddress($updateAddress->getAddress(), $updateAddress->getLanguage());
201
        $this->offerRepository->save($place);
202
    }
203
204
    /**
205
     * Handle the update of facilities for a place.
206
     * @param UpdateFacilities $updateFacilities
207
     */
208
    public function handleUpdateFacilities(UpdateFacilities $updateFacilities)
209
    {
210
211
        /** @var Place $place */
212
        $place = $this->offerRepository->load($updateFacilities->getItemId());
213
214
        $place->updateFacilities(
215
            $updateFacilities->getFacilities()
216
        );
217
218
        $this->offerRepository->save($place);
219
    }
220
221
    /**
222
     * Handle an update the major info command.
223
     * @param UpdateMajorInfo $updateMajorInfo
224
     */
225 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...
226
    {
227
228
        /** @var Place $place */
229
        $place = $this->offerRepository->load($updateMajorInfo->getItemId());
230
231
        $place->updateMajorInfo(
232
            $updateMajorInfo->getTitle(),
233
            $updateMajorInfo->getEventType(),
234
            $updateMajorInfo->getAddress(),
235
            $updateMajorInfo->getCalendar(),
236
            $updateMajorInfo->getTheme()
237
        );
238
239
        $this->offerRepository->save($place);
240
241
    }
242
}
243