1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace CultuurNet\UDB3\Event; |
4
|
|
|
|
5
|
|
|
use CultuurNet\UDB3\BookingInfo; |
6
|
|
|
use CultuurNet\UDB3\CalendarInterface; |
7
|
|
|
use CultuurNet\UDB3\Cdb\EventItemFactory; |
8
|
|
|
use CultuurNet\UDB3\Cdb\UpdateableWithCdbXmlInterface; |
9
|
|
|
use CultuurNet\UDB3\ContactPoint; |
10
|
|
|
use CultuurNet\UDB3\Event\Events\BookingInfoUpdated; |
11
|
|
|
use CultuurNet\UDB3\Event\Events\ContactPointUpdated; |
12
|
|
|
use CultuurNet\UDB3\Event\Events\DescriptionTranslated; |
13
|
|
|
use CultuurNet\UDB3\Event\Events\DescriptionUpdated; |
14
|
|
|
use CultuurNet\UDB3\Event\Events\EventCdbXMLInterface; |
15
|
|
|
use CultuurNet\UDB3\Event\Events\EventCreated; |
16
|
|
|
use CultuurNet\UDB3\Event\Events\EventCreatedFromCdbXml; |
17
|
|
|
use CultuurNet\UDB3\Event\Events\EventDeleted; |
18
|
|
|
use CultuurNet\UDB3\Event\Events\EventImportedFromUDB2; |
19
|
|
|
use CultuurNet\UDB3\Event\Events\EventUpdatedFromCdbXml; |
20
|
|
|
use CultuurNet\UDB3\Event\Events\EventUpdatedFromUDB2; |
21
|
|
|
use CultuurNet\UDB3\Event\Events\ImageAdded; |
22
|
|
|
use CultuurNet\UDB3\Event\Events\ImageRemoved; |
23
|
|
|
use CultuurNet\UDB3\Event\Events\ImageUpdated; |
24
|
|
|
use CultuurNet\UDB3\Event\Events\LabelAdded; |
25
|
|
|
use CultuurNet\UDB3\Event\Events\LabelRemoved; |
26
|
|
|
use CultuurNet\UDB3\Event\Events\LabelsMerged; |
27
|
|
|
use CultuurNet\UDB3\Event\Events\MainImageSelected; |
28
|
|
|
use CultuurNet\UDB3\Event\Events\MajorInfoUpdated; |
29
|
|
|
use CultuurNet\UDB3\Event\Events\Moderation\Approved; |
30
|
|
|
use CultuurNet\UDB3\Event\Events\Moderation\FlaggedAsDuplicate; |
31
|
|
|
use CultuurNet\UDB3\Event\Events\Moderation\FlaggedAsInappropriate; |
32
|
|
|
use CultuurNet\UDB3\Event\Events\Moderation\Published; |
33
|
|
|
use CultuurNet\UDB3\Event\Events\Moderation\Rejected; |
34
|
|
|
use CultuurNet\UDB3\Event\Events\OrganizerDeleted; |
35
|
|
|
use CultuurNet\UDB3\Event\Events\OrganizerUpdated; |
36
|
|
|
use CultuurNet\UDB3\Event\Events\PriceInfoUpdated; |
37
|
|
|
use CultuurNet\UDB3\Event\Events\TitleTranslated; |
38
|
|
|
use CultuurNet\UDB3\Event\Events\TranslationApplied; |
39
|
|
|
use CultuurNet\UDB3\Event\Events\TranslationDeleted; |
40
|
|
|
use CultuurNet\UDB3\Event\Events\TypicalAgeRangeDeleted; |
41
|
|
|
use CultuurNet\UDB3\Event\Events\TypicalAgeRangeUpdated; |
42
|
|
|
use CultuurNet\UDB3\EventXmlString; |
43
|
|
|
use CultuurNet\UDB3\Label; |
44
|
|
|
use CultuurNet\UDB3\LabelCollection; |
45
|
|
|
use CultuurNet\UDB3\Language; |
46
|
|
|
use CultuurNet\UDB3\Location\Location; |
47
|
|
|
use CultuurNet\UDB3\Offer\Commands\Image\AbstractUpdateImage; |
48
|
|
|
use CultuurNet\UDB3\Offer\Offer; |
49
|
|
|
use CultuurNet\UDB3\Media\Image; |
50
|
|
|
use CultuurNet\UDB3\PriceInfo\PriceInfo; |
51
|
|
|
use CultuurNet\UDB3\Offer\WorkflowStatus; |
52
|
|
|
use CultuurNet\UDB3\Theme; |
53
|
|
|
use CultuurNet\UDB3\Title; |
54
|
|
|
use CultuurNet\UDB3\Translation; |
55
|
|
|
use ValueObjects\Identity\UUID; |
56
|
|
|
use ValueObjects\String\String as StringLiteral; |
57
|
|
|
|
58
|
|
|
class Event extends Offer implements UpdateableWithCdbXmlInterface |
59
|
|
|
{ |
60
|
|
|
protected $eventId; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @var Translation[] |
64
|
|
|
*/ |
65
|
|
|
protected $translations = []; |
66
|
|
|
|
67
|
|
|
const MAIN_LANGUAGE_CODE = 'nl'; |
68
|
|
|
|
69
|
|
|
public function __construct() |
70
|
|
|
{ |
71
|
|
|
parent::__construct(); |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Factory method to create a new event. |
76
|
|
|
* |
77
|
|
|
* @param Title $title |
78
|
|
|
* @param EventType $eventType |
79
|
|
|
* @param Location $location |
80
|
|
|
* @param CalendarInterface $calendar |
81
|
|
|
* @param Theme|null $theme |
82
|
|
|
* @param \DateTimeImmutable|null $publicationDate |
83
|
|
|
* |
84
|
|
|
* @return Event |
85
|
|
|
*/ |
86
|
|
|
public static function create( |
87
|
|
|
$eventId, |
88
|
|
|
Title $title, |
89
|
|
|
EventType $eventType, |
90
|
|
|
Location $location, |
91
|
|
|
CalendarInterface $calendar, |
92
|
|
|
Theme $theme = null, |
93
|
|
|
\DateTimeImmutable $publicationDate = null |
94
|
|
|
) { |
95
|
|
|
if (!is_string($eventId)) { |
96
|
|
|
throw new \InvalidArgumentException( |
97
|
|
|
'Expected eventId to be a string, received ' . gettype($eventId) |
98
|
|
|
); |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
$event = new self(); |
102
|
|
|
|
103
|
|
|
$event->apply( |
104
|
|
|
new EventCreated( |
105
|
|
|
$eventId, |
106
|
|
|
$title, |
107
|
|
|
$eventType, |
108
|
|
|
$location, |
109
|
|
|
$calendar, |
110
|
|
|
$theme, |
111
|
|
|
$publicationDate |
112
|
|
|
) |
113
|
|
|
); |
114
|
|
|
|
115
|
|
|
return $event; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @param string $eventId |
120
|
|
|
* @param string $cdbXml |
121
|
|
|
* @param string $cdbXmlNamespaceUri |
122
|
|
|
* @return Event |
123
|
|
|
*/ |
124
|
|
|
public static function importFromUDB2( |
125
|
|
|
$eventId, |
126
|
|
|
$cdbXml, |
127
|
|
|
$cdbXmlNamespaceUri |
128
|
|
|
) { |
129
|
|
|
$event = new self(); |
130
|
|
|
$event->apply( |
131
|
|
|
new EventImportedFromUDB2( |
132
|
|
|
$eventId, |
133
|
|
|
$cdbXml, |
134
|
|
|
$cdbXmlNamespaceUri |
135
|
|
|
) |
136
|
|
|
); |
137
|
|
|
|
138
|
|
|
return $event; |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
/** |
142
|
|
|
* @param EventXmlString $xmlString |
143
|
|
|
* @param StringLiteral $eventId |
144
|
|
|
* @param StringLiteral $cdbXmlNamespaceUri |
145
|
|
|
* @return Event |
146
|
|
|
*/ |
147
|
|
|
public static function createFromCdbXml( |
148
|
|
|
StringLiteral $eventId, |
149
|
|
|
EventXmlString $xmlString, |
150
|
|
|
StringLiteral $cdbXmlNamespaceUri |
151
|
|
|
) { |
152
|
|
|
$event = new self(); |
153
|
|
|
$event->apply( |
154
|
|
|
new EventCreatedFromCdbXml( |
155
|
|
|
$eventId, |
156
|
|
|
$xmlString, |
157
|
|
|
$cdbXmlNamespaceUri |
158
|
|
|
) |
159
|
|
|
); |
160
|
|
|
|
161
|
|
|
return $event; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
/** |
165
|
|
|
* @param StringLiteral $eventId |
166
|
|
|
* @param EventXmlString $xmlString |
167
|
|
|
* @param StringLiteral $cdbXmlNamespaceUri |
168
|
|
|
* @return Event |
169
|
|
|
*/ |
170
|
|
|
public function updateFromCdbXml( |
171
|
|
|
StringLiteral $eventId, |
172
|
|
|
EventXmlString $xmlString, |
173
|
|
|
StringLiteral $cdbXmlNamespaceUri |
174
|
|
|
) { |
175
|
|
|
$this->apply( |
176
|
|
|
new EventUpdatedFromCdbXml( |
177
|
|
|
$eventId, |
178
|
|
|
$xmlString, |
179
|
|
|
$cdbXmlNamespaceUri |
180
|
|
|
) |
181
|
|
|
); |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* @param LabelCollection $labels |
186
|
|
|
*/ |
187
|
|
|
public function mergeLabels(LabelCollection $labels) |
188
|
|
|
{ |
189
|
|
|
if (count($labels) === 0) { |
190
|
|
|
throw new \InvalidArgumentException( |
191
|
|
|
'Argument $labels should contain at least one label' |
192
|
|
|
); |
193
|
|
|
} |
194
|
|
|
|
195
|
|
|
$this->apply( |
196
|
|
|
new LabelsMerged( |
197
|
|
|
new StringLiteral($this->eventId), |
198
|
|
|
$labels |
199
|
|
|
) |
200
|
|
|
); |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* @param Language $language |
205
|
|
|
* @param StringLiteral|null $title |
206
|
|
|
* @param StringLiteral|null $shortDescription |
207
|
|
|
* @param StringLiteral|null $longDescription |
208
|
|
|
*/ |
209
|
|
|
public function applyTranslation( |
210
|
|
|
Language $language, |
211
|
|
|
StringLiteral $title = null, |
212
|
|
|
StringLiteral $shortDescription = null, |
213
|
|
|
StringLiteral $longDescription = null |
214
|
|
|
) { |
215
|
|
|
$this->apply( |
216
|
|
|
new TranslationApplied( |
217
|
|
|
new StringLiteral($this->eventId), |
218
|
|
|
$language, |
219
|
|
|
$title, |
|
|
|
|
220
|
|
|
$shortDescription, |
|
|
|
|
221
|
|
|
$longDescription |
|
|
|
|
222
|
|
|
) |
223
|
|
|
); |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
/** |
227
|
|
|
* @param Language $language |
228
|
|
|
*/ |
229
|
|
|
public function deleteTranslation( |
230
|
|
|
Language $language |
231
|
|
|
) { |
232
|
|
|
if (!array_key_exists($language->getCode(), $this->translations)) { |
233
|
|
|
return; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
|
$this->apply( |
237
|
|
|
new TranslationDeleted( |
238
|
|
|
new StringLiteral($this->eventId), |
239
|
|
|
$language |
240
|
|
|
) |
241
|
|
|
); |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* {@inheritdoc} |
246
|
|
|
*/ |
247
|
|
|
public function getAggregateRootId() |
248
|
|
|
{ |
249
|
|
|
return $this->eventId; |
250
|
|
|
} |
251
|
|
|
|
252
|
|
|
/** |
253
|
|
|
* @return Translation[] |
254
|
|
|
*/ |
255
|
|
|
public function getTranslations() |
256
|
|
|
{ |
257
|
|
|
return $this->translations; |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
/** |
261
|
|
|
* @return UUID[] |
262
|
|
|
*/ |
263
|
|
|
public function getMediaObjects() |
264
|
|
|
{ |
265
|
|
|
return $this->mediaObjects; |
266
|
|
|
} |
267
|
|
|
|
268
|
|
|
protected function applyEventCreated(EventCreated $eventCreated) |
269
|
|
|
{ |
270
|
|
|
$this->eventId = $eventCreated->getEventId(); |
271
|
|
|
$this->workflowStatus = WorkflowStatus::DRAFT(); |
272
|
|
|
} |
273
|
|
|
|
274
|
|
|
protected function applyEventImportedFromUDB2( |
275
|
|
|
EventImportedFromUDB2 $eventImported |
276
|
|
|
) { |
277
|
|
|
$this->eventId = $eventImported->getEventId(); |
278
|
|
|
$this->setUDB2Data($eventImported); |
279
|
|
|
} |
280
|
|
|
|
281
|
|
|
/** |
282
|
|
|
* @param EventUpdatedFromUDB2 $eventUpdated |
283
|
|
|
*/ |
284
|
|
|
protected function applyEventUpdatedFromUDB2( |
285
|
|
|
EventUpdatedFromUDB2 $eventUpdated |
286
|
|
|
) { |
287
|
|
|
$this->setUDB2Data($eventUpdated); |
288
|
|
|
} |
289
|
|
|
|
290
|
|
|
/** |
291
|
|
|
* @param EventCdbXMLInterface $eventCdbXML |
292
|
|
|
*/ |
293
|
|
|
protected function setUDB2Data( |
294
|
|
|
EventCdbXMLInterface $eventCdbXML |
295
|
|
|
) { |
296
|
|
|
$udb2Event = EventItemFactory::createEventFromCdbXml( |
297
|
|
|
$eventCdbXML->getCdbXmlNamespaceUri(), |
298
|
|
|
$eventCdbXML->getCdbXml() |
299
|
|
|
); |
300
|
|
|
|
301
|
|
|
$this->importWorkflowStatus($udb2Event); |
302
|
|
|
$this->labels = LabelCollection::fromKeywords($udb2Event->getKeywords(true)); |
303
|
|
|
} |
304
|
|
|
|
305
|
|
|
/** |
306
|
|
|
* Update the major info. |
307
|
|
|
* |
308
|
|
|
* @param Title $title |
309
|
|
|
* @param EventType $eventType |
310
|
|
|
* @param Location $location |
311
|
|
|
* @param CalendarInterface $calendar |
312
|
|
|
* @param type $theme |
313
|
|
|
*/ |
314
|
|
|
public function updateMajorInfo( |
315
|
|
|
Title $title, |
316
|
|
|
EventType $eventType, |
317
|
|
|
Location $location, |
318
|
|
|
CalendarInterface $calendar, |
319
|
|
|
$theme = null |
320
|
|
|
) { |
321
|
|
|
$this->apply(new MajorInfoUpdated($this->eventId, $title, $eventType, $location, $calendar, $theme)); |
322
|
|
|
} |
323
|
|
|
|
324
|
|
|
protected function applyEventCreatedFromCdbXml( |
325
|
|
|
EventCreatedFromCdbXml $eventCreatedFromCdbXml |
326
|
|
|
) { |
327
|
|
|
$this->eventId = $eventCreatedFromCdbXml->getEventId()->toNative(); |
328
|
|
|
|
329
|
|
|
$udb2Event = EventItemFactory::createEventFromCdbXml( |
330
|
|
|
$eventCreatedFromCdbXml->getCdbXmlNamespaceUri(), |
331
|
|
|
$eventCreatedFromCdbXml->getEventXmlString()->toEventXmlString() |
332
|
|
|
); |
333
|
|
|
|
334
|
|
|
$this->labels = LabelCollection::fromKeywords($udb2Event->getKeywords(true)); |
335
|
|
|
} |
336
|
|
|
|
337
|
|
|
protected function applyEventUpdatedFromCdbXml( |
338
|
|
|
EventUpdatedFromCdbXml $eventUpdatedFromCdbXml |
339
|
|
|
) { |
340
|
|
|
$this->eventId = $eventUpdatedFromCdbXml->getEventId()->toNative(); |
341
|
|
|
|
342
|
|
|
$udb2Event = EventItemFactory::createEventFromCdbXml( |
343
|
|
|
$eventUpdatedFromCdbXml->getCdbXmlNamespaceUri(), |
344
|
|
|
$eventUpdatedFromCdbXml->getEventXmlString()->toEventXmlString() |
345
|
|
|
); |
346
|
|
|
|
347
|
|
|
$this->labels = LabelCollection::fromKeywords($udb2Event->getKeywords(true)); |
348
|
|
|
} |
349
|
|
|
|
350
|
|
|
protected function applyLabelsMerged( |
351
|
|
|
LabelsMerged $labelsMerged |
352
|
|
|
) { |
353
|
|
|
$this->labels = $this->labels->merge($labelsMerged->getLabels()); |
354
|
|
|
} |
355
|
|
|
|
356
|
|
|
protected function applyTranslationApplied( |
357
|
|
|
TranslationApplied $translationApplied |
358
|
|
|
) { |
359
|
|
|
$this->eventId = $translationApplied->getEventId()->toNative(); |
360
|
|
|
|
361
|
|
|
$language = $translationApplied->getLanguage()->getCode(); |
362
|
|
|
$translation = new Translation( |
363
|
|
|
$translationApplied->getLanguage(), |
364
|
|
|
$translationApplied->getTitle(), |
365
|
|
|
$translationApplied->getShortdescription(), |
366
|
|
|
$translationApplied->getLongdescription() |
367
|
|
|
); |
368
|
|
|
|
369
|
|
|
if (!array_key_exists($language, $this->translations)) { |
370
|
|
|
$this->translations[$language] = $translation; |
371
|
|
|
} else { |
372
|
|
|
$newTranslation = $this->translations[$language]->mergeTranslation($translation); |
373
|
|
|
$this->translations[$language] = $newTranslation; |
374
|
|
|
} |
375
|
|
|
} |
376
|
|
|
|
377
|
|
|
protected function applyTranslationDeleted( |
378
|
|
|
TranslationDeleted $translationDeleted |
379
|
|
|
) { |
380
|
|
|
$language = $translationDeleted->getLanguage()->getCode(); |
381
|
|
|
|
382
|
|
|
if (array_key_exists($language, $this->translations)) { |
383
|
|
|
unset($this->translations[$language]); |
384
|
|
|
} |
385
|
|
|
} |
386
|
|
|
|
387
|
|
|
/** |
388
|
|
|
* @inheritdoc |
389
|
|
|
*/ |
390
|
|
|
public function updateWithCdbXml($cdbXml, $cdbXmlNamespaceUri) |
391
|
|
|
{ |
392
|
|
|
$this->apply( |
393
|
|
|
new EventUpdatedFromUDB2( |
394
|
|
|
$this->eventId, |
395
|
|
|
$cdbXml, |
396
|
|
|
$cdbXmlNamespaceUri |
397
|
|
|
) |
398
|
|
|
); |
399
|
|
|
} |
400
|
|
|
|
401
|
|
|
/** |
402
|
|
|
* @param Label $label |
403
|
|
|
* @return LabelAdded |
404
|
|
|
*/ |
405
|
|
|
protected function createLabelAddedEvent(Label $label) |
406
|
|
|
{ |
407
|
|
|
return new LabelAdded($this->eventId, $label); |
408
|
|
|
} |
409
|
|
|
|
410
|
|
|
/** |
411
|
|
|
* @param Label $label |
412
|
|
|
* @return LabelRemoved |
413
|
|
|
*/ |
414
|
|
|
protected function createLabelRemovedEvent(Label $label) |
415
|
|
|
{ |
416
|
|
|
return new LabelRemoved($this->eventId, $label); |
417
|
|
|
} |
418
|
|
|
|
419
|
|
|
/** |
420
|
|
|
* @param Image $image |
421
|
|
|
* @return ImageAdded |
422
|
|
|
*/ |
423
|
|
|
protected function createImageAddedEvent(Image $image) |
424
|
|
|
{ |
425
|
|
|
return new ImageAdded($this->eventId, $image); |
426
|
|
|
} |
427
|
|
|
|
428
|
|
|
/** |
429
|
|
|
* @param Image $image |
430
|
|
|
* @return ImageRemoved |
431
|
|
|
*/ |
432
|
|
|
protected function createImageRemovedEvent(Image $image) |
433
|
|
|
{ |
434
|
|
|
return new ImageRemoved($this->eventId, $image); |
435
|
|
|
} |
436
|
|
|
|
437
|
|
|
/** |
438
|
|
|
* @param AbstractUpdateImage $updateImageCommand |
439
|
|
|
* @return ImageUpdated |
440
|
|
|
*/ |
441
|
|
|
protected function createImageUpdatedEvent( |
442
|
|
|
AbstractUpdateImage $updateImageCommand |
443
|
|
|
) { |
444
|
|
|
return new ImageUpdated( |
445
|
|
|
$this->eventId, |
446
|
|
|
$updateImageCommand->getMediaObjectId(), |
447
|
|
|
$updateImageCommand->getDescription(), |
448
|
|
|
$updateImageCommand->getCopyrightHolder() |
449
|
|
|
); |
450
|
|
|
} |
451
|
|
|
|
452
|
|
|
/** |
453
|
|
|
* @param Image $image |
454
|
|
|
* @return MainImageSelected |
455
|
|
|
*/ |
456
|
|
|
protected function createMainImageSelectedEvent(Image $image) |
457
|
|
|
{ |
458
|
|
|
return new MainImageSelected($this->eventId, $image); |
459
|
|
|
} |
460
|
|
|
|
461
|
|
|
/** |
462
|
|
|
* @param Language $language |
463
|
|
|
* @param StringLiteral $title |
464
|
|
|
* @return TitleTranslated |
465
|
|
|
*/ |
466
|
|
|
protected function createTitleTranslatedEvent(Language $language, StringLiteral $title) |
467
|
|
|
{ |
468
|
|
|
return new TitleTranslated($this->eventId, $language, $title); |
469
|
|
|
} |
470
|
|
|
|
471
|
|
|
/** |
472
|
|
|
* @param Language $language |
473
|
|
|
* @param StringLiteral $description |
474
|
|
|
* @return DescriptionTranslated |
475
|
|
|
*/ |
476
|
|
|
protected function createDescriptionTranslatedEvent(Language $language, StringLiteral $description) |
477
|
|
|
{ |
478
|
|
|
return new DescriptionTranslated($this->eventId, $language, $description); |
479
|
|
|
} |
480
|
|
|
|
481
|
|
|
/** |
482
|
|
|
* @param string $description |
483
|
|
|
* @return DescriptionUpdated |
484
|
|
|
*/ |
485
|
|
|
protected function createDescriptionUpdatedEvent($description) |
486
|
|
|
{ |
487
|
|
|
return new DescriptionUpdated($this->eventId, $description); |
488
|
|
|
} |
489
|
|
|
|
490
|
|
|
/** |
491
|
|
|
* @param string $typicalAgeRange |
492
|
|
|
* @return TypicalAgeRangeUpdated |
493
|
|
|
*/ |
494
|
|
|
protected function createTypicalAgeRangeUpdatedEvent($typicalAgeRange) |
495
|
|
|
{ |
496
|
|
|
return new TypicalAgeRangeUpdated($this->eventId, $typicalAgeRange); |
497
|
|
|
} |
498
|
|
|
|
499
|
|
|
/** |
500
|
|
|
* @return TypicalAgeRangeDeleted |
501
|
|
|
*/ |
502
|
|
|
protected function createTypicalAgeRangeDeletedEvent() |
503
|
|
|
{ |
504
|
|
|
return new TypicalAgeRangeDeleted($this->eventId); |
505
|
|
|
} |
506
|
|
|
|
507
|
|
|
/** |
508
|
|
|
* @param string $organizerId |
509
|
|
|
* @return OrganizerUpdated |
510
|
|
|
*/ |
511
|
|
|
protected function createOrganizerUpdatedEvent($organizerId) |
512
|
|
|
{ |
513
|
|
|
return new OrganizerUpdated($this->eventId, $organizerId); |
514
|
|
|
} |
515
|
|
|
|
516
|
|
|
/** |
517
|
|
|
* @param string $organizerId |
518
|
|
|
* @return OrganizerDeleted |
519
|
|
|
*/ |
520
|
|
|
protected function createOrganizerDeletedEvent($organizerId) |
521
|
|
|
{ |
522
|
|
|
return new OrganizerDeleted($this->eventId, $organizerId); |
523
|
|
|
} |
524
|
|
|
|
525
|
|
|
/** |
526
|
|
|
* @param ContactPoint $contactPoint |
527
|
|
|
* @return ContactPointUpdated |
528
|
|
|
*/ |
529
|
|
|
protected function createContactPointUpdatedEvent(ContactPoint $contactPoint) |
530
|
|
|
{ |
531
|
|
|
return new ContactPointUpdated($this->eventId, $contactPoint); |
532
|
|
|
} |
533
|
|
|
|
534
|
|
|
/** |
535
|
|
|
* @param BookingInfo $bookingInfo |
536
|
|
|
* @return BookingInfoUpdated |
537
|
|
|
*/ |
538
|
|
|
protected function createBookingInfoUpdatedEvent(BookingInfo $bookingInfo) |
539
|
|
|
{ |
540
|
|
|
return new BookingInfoUpdated($this->eventId, $bookingInfo); |
541
|
|
|
} |
542
|
|
|
|
543
|
|
|
/** |
544
|
|
|
* @param PriceInfo $priceInfo |
545
|
|
|
* @return PriceInfoUpdated |
546
|
|
|
*/ |
547
|
|
|
protected function createPriceInfoUpdatedEvent(PriceInfo $priceInfo) |
548
|
|
|
{ |
549
|
|
|
return new PriceInfoUpdated($this->eventId, $priceInfo); |
550
|
|
|
} |
551
|
|
|
|
552
|
|
|
/** |
553
|
|
|
* @return EventDeleted |
554
|
|
|
*/ |
555
|
|
|
protected function createOfferDeletedEvent() |
556
|
|
|
{ |
557
|
|
|
return new EventDeleted($this->eventId); |
558
|
|
|
} |
559
|
|
|
|
560
|
|
|
/** |
561
|
|
|
* @inheritdoc |
562
|
|
|
*/ |
563
|
|
|
protected function createPublishedEvent(\DateTimeInterface $publicationDate) |
564
|
|
|
{ |
565
|
|
|
return new Published($this->eventId, $publicationDate); |
566
|
|
|
} |
567
|
|
|
|
568
|
|
|
/** |
569
|
|
|
* @inheritdoc |
570
|
|
|
*/ |
571
|
|
|
protected function createApprovedEvent() |
572
|
|
|
{ |
573
|
|
|
return new Approved($this->eventId); |
574
|
|
|
} |
575
|
|
|
|
576
|
|
|
/** |
577
|
|
|
* @inheritdoc |
578
|
|
|
*/ |
579
|
|
|
protected function createRejectedEvent(StringLiteral $reason) |
580
|
|
|
{ |
581
|
|
|
return new Rejected($this->eventId, $reason); |
582
|
|
|
} |
583
|
|
|
|
584
|
|
|
/** |
585
|
|
|
* @inheritDoc |
586
|
|
|
*/ |
587
|
|
|
protected function createFlaggedAsDuplicate() |
588
|
|
|
{ |
589
|
|
|
return new FlaggedAsDuplicate($this->eventId); |
590
|
|
|
} |
591
|
|
|
|
592
|
|
|
/** |
593
|
|
|
* @inheritDoc |
594
|
|
|
*/ |
595
|
|
|
protected function createFlaggedAsInappropriate() |
596
|
|
|
{ |
597
|
|
|
return new FlaggedAsInappropriate($this->eventId); |
598
|
|
|
} |
599
|
|
|
} |
600
|
|
|
|
This check looks at variables that have been passed in as parameters and are passed out again to other methods.
If the outgoing method call has stricter type requirements than the method itself, an issue is raised.
An additional type check may prevent trouble.