Completed
Push — master ( 65255d...9dfb0b )
by Luc
07:57 queued 02:17
created

Offer::updateCalendar()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace CultuurNet\UDB3\Offer;
4
5
use Broadway\EventSourcing\EventSourcedAggregateRoot;
6
use CultureFeed_Cdb_Item_Base;
7
use CultuurNet\UDB3\BookingInfo;
8
use CultuurNet\UDB3\Calendar;
9
use CultuurNet\UDB3\ContactPoint;
10
use CultuurNet\UDB3\Description;
11
use CultuurNet\UDB3\Label;
12
use CultuurNet\UDB3\LabelAwareAggregateRoot;
13
use CultuurNet\UDB3\LabelCollection;
14
use CultuurNet\UDB3\Media\Image;
15
use CultuurNet\UDB3\Media\ImageCollection;
16
use CultuurNet\UDB3\Offer\Commands\Image\AbstractUpdateImage;
17
use CultuurNet\UDB3\Language;
18
use CultuurNet\UDB3\Offer\Events\AbstractBookingInfoUpdated;
19
use CultuurNet\UDB3\Offer\Events\AbstractContactPointUpdated;
20
use CultuurNet\UDB3\Offer\Events\AbstractTitleTranslated;
21
use CultuurNet\UDB3\Offer\Events\AbstractTitleUpdated;
22
use CultuurNet\UDB3\Offer\Events\AbstractDescriptionTranslated;
23
use CultuurNet\UDB3\Offer\Events\AbstractDescriptionUpdated;
24
use CultuurNet\UDB3\Offer\Events\AbstractLabelAdded;
25
use CultuurNet\UDB3\Offer\Events\AbstractLabelRemoved;
26
use CultuurNet\UDB3\Offer\Events\AbstractOfferDeleted;
27
use CultuurNet\UDB3\Offer\Events\AbstractOrganizerDeleted;
28
use CultuurNet\UDB3\Offer\Events\AbstractOrganizerUpdated;
29
use CultuurNet\UDB3\Offer\Events\AbstractPriceInfoUpdated;
30
use CultuurNet\UDB3\Offer\Events\AbstractTypicalAgeRangeDeleted;
31
use CultuurNet\UDB3\Offer\Events\AbstractTypicalAgeRangeUpdated;
32
use CultuurNet\UDB3\Offer\Events\Image\AbstractImageAdded;
33
use CultuurNet\UDB3\Offer\Events\Image\AbstractImageRemoved;
34
use CultuurNet\UDB3\Offer\Events\Image\AbstractImagesEvent;
35
use CultuurNet\UDB3\Offer\Events\Image\AbstractImagesImportedFromUDB2;
36
use CultuurNet\UDB3\Offer\Events\Image\AbstractImagesUpdatedFromUDB2;
37
use CultuurNet\UDB3\Offer\Events\Image\AbstractImageUpdated;
38
use CultuurNet\UDB3\Offer\Events\Image\AbstractMainImageSelected;
39
use CultuurNet\UDB3\Offer\Events\Moderation\AbstractApproved;
40
use CultuurNet\UDB3\Offer\Events\Moderation\AbstractFlaggedAsDuplicate;
41
use CultuurNet\UDB3\Offer\Events\Moderation\AbstractFlaggedAsInappropriate;
42
use CultuurNet\UDB3\Offer\Events\Moderation\AbstractPublished;
43
use CultuurNet\UDB3\Offer\Events\Moderation\AbstractRejected;
44
use CultuurNet\UDB3\PriceInfo\PriceInfo;
45
use CultuurNet\UDB3\Title;
46
use Exception;
47
use ValueObjects\Identity\UUID;
48
use ValueObjects\StringLiteral\StringLiteral;
49
50
abstract class Offer extends EventSourcedAggregateRoot implements LabelAwareAggregateRoot
51
{
52
    const DUPLICATE_REASON = 'duplicate';
53
    const INAPPROPRIATE_REASON = 'inappropriate';
54
55
    /**
56
     * @var LabelCollection
57
     */
58
    protected $labels;
59
60
    /**
61
     * @var ImageCollection
62
     */
63
    protected $images;
64
65
    /**
66
     * @var string
67
     *
68
     * Organizer ids can come from UDB2 which does not strictly use UUIDs.
69
     */
70
    protected $organizerId;
71
72
    /**
73
     * @var WorkflowStatus
74
     */
75
    protected $workflowStatus;
76
77
    /**
78
     * @var StringLiteral|null
79
     */
80
    protected $rejectedReason;
81
82
    /**
83
     * @var PriceInfo
84
     */
85
    protected $priceInfo;
86
87
    /**
88
     * @var StringLiteral[]
89
     */
90
    protected $titles;
91
92
    /**
93
     * @var Description[]
94
     */
95
    protected $descriptions;
96
97
    /**
98
     * @var Language
99
     */
100
    protected $mainLanguage;
101
102
    /**
103
     * Offer constructor.
104
     */
105
    public function __construct()
106
    {
107
        // For now the main language is hard coded on nl.
108
        // In the future it should be set on create.
109
        $this->mainLanguage = new Language('nl');
110
111
        $this->titles = [];
112
        $this->descriptions = [];
113
        $this->labels = new LabelCollection();
114
        $this->images = new ImageCollection();
115
    }
116
117
    /**
118
     * Get the id of the main image if one is selected for this offer.
119
     *
120
     * @return UUID|null
121
     */
122
    protected function getMainImageId()
123
    {
124
        $mainImage = $this->images->getMain();
125
        return isset($mainImage) ? $mainImage->getMediaObjectId() : null;
126
    }
127
128
    /**
129
     * @inheritdoc
130
     */
131
    public function addLabel(Label $label)
132
    {
133
        if (!$this->labels->contains($label)) {
134
            $this->apply(
135
                $this->createLabelAddedEvent($label)
136
            );
137
        }
138
    }
139
140
    /**
141
     * @inheritdoc
142
     */
143
    public function removeLabel(Label $label)
144
    {
145
        if ($this->labels->contains($label)) {
146
            $this->apply(
147
                $this->createLabelRemovedEvent($label)
148
            );
149
        }
150
    }
151
152
    /**
153
     * @param Language $language
154
     * @param Title $title
155
     */
156
    public function updateTitle(Language $language, Title $title)
157
    {
158
        if ($this->isTitleChanged($title, $language)) {
159
            if ($language->getCode() !== $this->mainLanguage->getCode()) {
160
                $event = $this->createTitleTranslatedEvent($language, $title);
161
            } else {
162
                $event = $this->createTitleUpdatedEvent($title);
163
            }
164
165
            $this->apply($event);
166
        }
167
    }
168
169
    /**
170
     * @param Description $description
171
     * @param Language $language
172
     */
173
    public function updateDescription(Description $description, Language $language)
174
    {
175
        if ($this->isDescriptionChanged($description, $language)) {
176
            if ($language->getCode() !== $this->mainLanguage->getCode()) {
177
                $event = $this->createDescriptionTranslatedEvent($language, $description);
178
            } else {
179
                $event = $this->createDescriptionUpdatedEvent((string) $description);
180
            }
181
182
            $this->apply($event);
183
        }
184
    }
185
186
    /**
187
     * @param Calendar $calendar
188
     */
189
    public function updateCalendar(Calendar $calendar)
190
    {
191
        // For now no special business rules for updating the calendar.
192
        $this->apply(
193
            $this->createCalendarUpdatedEvent($calendar)
194
        );
195
    }
196
197
    /**
198
     * @param string $typicalAgeRange
199
     */
200
    public function updateTypicalAgeRange($typicalAgeRange)
201
    {
202
        $this->apply(
203
            $this->createTypicalAgeRangeUpdatedEvent($typicalAgeRange)
204
        );
205
    }
206
207
    public function deleteTypicalAgeRange()
208
    {
209
        $this->apply(
210
            $this->createTypicalAgeRangeDeletedEvent()
211
        );
212
    }
213
214
    /**
215
     * @param string $organizerId
216
     */
217
    public function updateOrganizer($organizerId)
218
    {
219
        if ($this->organizerId !== $organizerId) {
220
            $this->apply(
221
                $this->createOrganizerUpdatedEvent($organizerId)
222
            );
223
        }
224
    }
225
226
    /**
227
     * Delete the given organizer.
228
     *
229
     * @param string $organizerId
230
     */
231
    public function deleteOrganizer($organizerId)
232
    {
233
        if ($this->organizerId === $organizerId) {
234
            $this->apply(
235
                $this->createOrganizerDeletedEvent($organizerId)
236
            );
237
        }
238
    }
239
240
    /**
241
     * Updated the contact info.
242
     * @param ContactPoint $contactPoint
243
     */
244
    public function updateContactPoint(ContactPoint $contactPoint)
245
    {
246
        $this->apply(
247
            $this->createContactPointUpdatedEvent($contactPoint)
248
        );
249
    }
250
251
    /**
252
     * Updated the booking info.
253
     *
254
     * @param BookingInfo $bookingInfo
255
     */
256
    public function updateBookingInfo(BookingInfo $bookingInfo)
257
    {
258
        $this->apply(
259
            $this->createBookingInfoUpdatedEvent($bookingInfo)
260
        );
261
    }
262
263
    /**
264
     * @param PriceInfo $priceInfo
265
     */
266
    public function updatePriceInfo(PriceInfo $priceInfo)
267
    {
268
        if (is_null($this->priceInfo) || $priceInfo->serialize() !== $this->priceInfo->serialize()) {
269
            $this->apply(
270
                $this->createPriceInfoUpdatedEvent($priceInfo)
271
            );
272
        }
273
    }
274
275
    /**
276
     * @param AbstractPriceInfoUpdated $priceInfoUpdated
277
     */
278
    protected function applyPriceInfoUpdated(AbstractPriceInfoUpdated $priceInfoUpdated)
279
    {
280
        $this->priceInfo = $priceInfoUpdated->getPriceInfo();
281
    }
282
283
    /**
284
     * @param AbstractLabelAdded $labelAdded
285
     */
286
    protected function applyLabelAdded(AbstractLabelAdded $labelAdded)
287
    {
288
        $this->labels = $this->labels->with($labelAdded->getLabel());
289
    }
290
291
    /**
292
     * @param AbstractLabelRemoved $labelRemoved
293
     */
294
    protected function applyLabelRemoved(AbstractLabelRemoved $labelRemoved)
295
    {
296
        $this->labels = $this->labels->without($labelRemoved->getLabel());
297
    }
298
299
    protected function applyDescriptionUpdated(AbstractDescriptionUpdated $descriptionUpdated)
300
    {
301
        $mainLanguageCode = $this->mainLanguage->getCode();
302
        $this->descriptions[$mainLanguageCode] = new Description($descriptionUpdated->getDescription());
303
    }
304
305
    protected function applyDescriptionTranslated(AbstractDescriptionTranslated $descriptionTranslated)
306
    {
307
        $languageCode = $descriptionTranslated->getLanguage()->getCode();
308
        $this->descriptions[$languageCode] = $descriptionTranslated->getDescription();
309
    }
310
311
    /**
312
     * Add a new image.
313
     *
314
     * @param Image $image
315
     */
316
    public function addImage(Image $image)
317
    {
318
        if (!$this->images->contains($image)) {
319
            $this->apply(
320
                $this->createImageAddedEvent($image)
321
            );
322
        }
323
    }
324
325
    /**
326
     * @param AbstractUpdateImage $updateImageCommand
327
     */
328
    public function updateImage(AbstractUpdateImage $updateImageCommand)
329
    {
330
        if ($this->images->findImageByUUID($updateImageCommand->getMediaObjectId())) {
331
            $this->apply(
332
                $this->createImageUpdatedEvent($updateImageCommand)
333
            );
334
        }
335
    }
336
337
    /**
338
     * Remove an image.
339
     *
340
     * @param Image $image
341
     */
342
    public function removeImage(Image $image)
343
    {
344
        if ($this->images->contains($image)) {
345
            $this->apply(
346
                $this->createImageRemovedEvent($image)
347
            );
348
        }
349
    }
350
351
    /**
352
     * Make an existing image of the item the main image.
353
     *
354
     * @param Image $image
355
     */
356
    public function selectMainImage(Image $image)
357
    {
358
        if (!$this->images->contains($image)) {
359
            throw new \InvalidArgumentException('You can not select a random image to be main, it has to be added to the item.');
360
        }
361
362
        $oldMainImage = $this->images->getMain();
363
364
        if (!isset($oldMainImage) || $oldMainImage->getMediaObjectId() !== $image->getMediaObjectId()) {
365
            $this->apply(
366
                $this->createMainImageSelectedEvent($image)
367
            );
368
        }
369
    }
370
371
    /**
372
     * Delete the offer.
373
     */
374
    public function delete()
375
    {
376
        $this->apply(
377
            $this->createOfferDeletedEvent()
378
        );
379
    }
380
381
    /**
382
     * @param CultureFeed_Cdb_Item_Base $cdbItem
383
     */
384
    protected function importWorkflowStatus(CultureFeed_Cdb_Item_Base $cdbItem)
385
    {
386
        try {
387
            $workflowStatus = WorkflowStatus::fromNative($cdbItem->getWfStatus());
388
        } catch (\InvalidArgumentException $exception) {
389
            $workflowStatus = WorkflowStatus::READY_FOR_VALIDATION();
390
        }
391
        $this->workflowStatus = $workflowStatus;
392
    }
393
394
    /**
395
     * Publish the offer when it has workflowstatus draft.
396
     * @param \DateTimeInterface $publicationDate
397
     */
398
    public function publish(\DateTimeInterface $publicationDate)
399
    {
400
        $this->guardPublish() ?: $this->apply(
401
            $this->createPublishedEvent($publicationDate)
402
        );
403
    }
404
405
    /**
406
     * @return bool
407
     * @throws Exception
408
     */
409 View Code Duplication
    private function guardPublish()
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...
410
    {
411
        if ($this->workflowStatus === WorkflowStatus::READY_FOR_VALIDATION()) {
412
            return true; // nothing left to do if the offer has already been published
413
        }
414
415
        if ($this->workflowStatus !== WorkflowStatus::DRAFT()) {
416
            throw new Exception('You can not publish an offer that is not draft');
417
        }
418
419
        return false;
420
    }
421
422
    /**
423
     * Approve the offer when it's waiting for validation.
424
     */
425
    public function approve()
426
    {
427
        $this->guardApprove() ?: $this->apply($this->createApprovedEvent());
428
    }
429
430
    /**
431
     * @return bool
432
     * @throws Exception
433
     */
434 View Code Duplication
    private function guardApprove()
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...
435
    {
436
        if ($this->workflowStatus === WorkflowStatus::APPROVED()) {
437
            return true; // nothing left to do if the offer has already been approved
438
        }
439
440
        if ($this->workflowStatus !== WorkflowStatus::READY_FOR_VALIDATION()) {
441
            throw new Exception('You can not approve an offer that is not ready for validation');
442
        }
443
444
        return false;
445
    }
446
447
    /**
448
     * Reject an offer that is waiting for validation with a given reason.
449
     * @param StringLiteral $reason
450
     */
451
    public function reject(StringLiteral $reason)
452
    {
453
        $this->guardRejection($reason) ?: $this->apply($this->createRejectedEvent($reason));
454
    }
455
456
    public function flagAsDuplicate()
457
    {
458
        $reason = new StringLiteral(self::DUPLICATE_REASON);
459
        $this->guardRejection($reason) ?: $this->apply($this->createFlaggedAsDuplicate());
460
    }
461
462
    public function flagAsInappropriate()
463
    {
464
        $reason = new StringLiteral(self::INAPPROPRIATE_REASON);
465
        $this->guardRejection($reason) ?: $this->apply($this->createFlaggedAsInappropriate());
466
    }
467
468
    /**
469
     * @param StringLiteral $reason
470
     * @return bool
471
     *  false when the offer can still be rejected, true when the offer is already rejected for the same reason
472
     * @throws Exception
473
     */
474
    private function guardRejection(StringLiteral $reason)
475
    {
476
        if ($this->workflowStatus === WorkflowStatus::REJECTED()) {
477
            if ($this->rejectedReason && $reason->sameValueAs($this->rejectedReason)) {
478
                return true; // nothing left to do if the offer has already been rejected for the same reason
479
            } else {
480
                throw new Exception('The offer has already been rejected for another reason: ' . $this->rejectedReason);
481
            }
482
        }
483
484
        if ($this->workflowStatus !== WorkflowStatus::READY_FOR_VALIDATION()) {
485
            throw new Exception('You can not reject an offer that is not ready for validation');
486
        }
487
488
        return false;
489
    }
490
491
    /**
492
     * @param Title $title
493
     * @param Language $language
494
     * @return bool
495
     */
496 View Code Duplication
    private function isTitleChanged(Title $title, Language $language)
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...
497
    {
498
        $languageCode = $language->getCode();
499
500
        return !isset($this->titles[$languageCode]) ||
501
            !$title->sameValueAs($this->titles[$languageCode]);
502
    }
503
504
    /**
505
     * @param Description $description
506
     * @param Language $language
507
     * @return bool
508
     */
509 View Code Duplication
    private function isDescriptionChanged(Description $description, Language $language)
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...
510
    {
511
        $languageCode = $language->getCode();
512
513
        return !isset($this->descriptions[$languageCode]) ||
514
            !$description->sameValueAs($this->descriptions[$languageCode]);
515
    }
516
517
    /**
518
     * Overwrites or resets the main image and all media objects
519
     * by importing a new collection of images from UDB2.
520
     *
521
     * @param ImageCollection $images
522
     */
523
    public function importImagesFromUDB2(ImageCollection $images)
524
    {
525
        $this->apply($this->createImagesImportedFromUDB2($images));
526
    }
527
528
    /**
529
     * Overwrites or resets the main image and all media objects
530
     * by updating with a new collection of images from UDB2.
531
     *
532
     * @param ImageCollection $images
533
     */
534
    public function updateImagesFromUDB2(ImageCollection $images)
535
    {
536
        $this->apply($this->createImagesUpdatedFromUDB2($images));
537
    }
538
539
    /**
540
     * @param AbstractPublished $published
541
     */
542
    protected function applyPublished(AbstractPublished $published)
0 ignored issues
show
Unused Code introduced by
The parameter $published is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
543
    {
544
        $this->workflowStatus = WorkflowStatus::READY_FOR_VALIDATION();
545
    }
546
547
    /**
548
     * @param AbstractApproved $approved
549
     */
550
    protected function applyApproved(AbstractApproved $approved)
0 ignored issues
show
Unused Code introduced by
The parameter $approved is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
551
    {
552
        $this->workflowStatus = WorkflowStatus::APPROVED();
553
    }
554
555
    /**
556
     * @param AbstractRejected $rejected
557
     */
558
    protected function applyRejected(AbstractRejected $rejected)
559
    {
560
        $this->rejectedReason = $rejected->getReason();
561
        $this->workflowStatus = WorkflowStatus::REJECTED();
562
    }
563
564
    /**
565
     * @param AbstractFlaggedAsDuplicate $flaggedAsDuplicate
566
     */
567
    protected function applyFlaggedAsDuplicate(AbstractFlaggedAsDuplicate $flaggedAsDuplicate)
0 ignored issues
show
Unused Code introduced by
The parameter $flaggedAsDuplicate is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
568
    {
569
        $this->rejectedReason = new StringLiteral(self::DUPLICATE_REASON);
570
        $this->workflowStatus = WorkflowStatus::REJECTED();
571
    }
572
573
    /**
574
     * @param AbstractFlaggedAsInappropriate $flaggedAsInappropriate
575
     */
576
    protected function applyFlaggedAsInappropriate(AbstractFlaggedAsInappropriate $flaggedAsInappropriate)
0 ignored issues
show
Unused Code introduced by
The parameter $flaggedAsInappropriate is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
577
    {
578
        $this->rejectedReason = new StringLiteral(self::INAPPROPRIATE_REASON);
579
        $this->workflowStatus = WorkflowStatus::REJECTED();
580
    }
581
582
    protected function applyImageAdded(AbstractImageAdded $imageAdded)
583
    {
584
        $this->images = $this->images->with($imageAdded->getImage());
585
    }
586
587
    protected function applyImageRemoved(AbstractImageRemoved $imageRemoved)
588
    {
589
        $this->images = $this->images->without($imageRemoved->getImage());
590
    }
591
592
    protected function applyMainImageSelected(AbstractMainImageSelected $mainImageSelected)
593
    {
594
        $this->images = $this->images->withMain($mainImageSelected->getImage());
595
    }
596
597
    protected function applyOrganizerUpdated(AbstractOrganizerUpdated $organizerUpdated)
598
    {
599
        $this->organizerId = $organizerUpdated->getOrganizerId();
600
    }
601
602
    protected function applyOrganizerDeleted(AbstractOrganizerDeleted $organizerDeleted)
0 ignored issues
show
Unused Code introduced by
The parameter $organizerDeleted is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
603
    {
604
        $this->organizerId = null;
605
    }
606
607
    /**
608
     * @param AbstractImagesImportedFromUDB2 $imagesImportedFromUDB2
609
     */
610
    protected function applyImagesImportedFromUDB2(AbstractImagesImportedFromUDB2 $imagesImportedFromUDB2)
611
    {
612
        $this->applyUdb2ImagesEvent($imagesImportedFromUDB2);
613
    }
614
615
    /**
616
     * @param AbstractImagesUpdatedFromUDB2 $imagesUpdatedFromUDB2
617
     */
618
    protected function applyImagesUpdatedFromUDB2(AbstractImagesUpdatedFromUDB2 $imagesUpdatedFromUDB2)
619
    {
620
        $this->applyUdb2ImagesEvent($imagesUpdatedFromUDB2);
621
    }
622
623
    /**
624
     * This indirect apply method can be called internally to deal with images coming from UDB2.
625
     * Imports from UDB2 only contain the native Dutch content.
626
     * @see https://github.com/cultuurnet/udb3-udb2-bridge/blob/db0a7ab2444f55bb3faae3d59b82b39aaeba253b/test/Media/ImageCollectionFactoryTest.php#L79-L103
627
     * Because of this we have to make sure translated images are left in place.
628
     *
629
     * @param AbstractImagesEvent $imagesEvent
630
     */
631
    protected function applyUdb2ImagesEvent(AbstractImagesEvent $imagesEvent)
632
    {
633
        $newMainImage = $imagesEvent->getImages()->getMain();
634
        $dutchImagesList = $imagesEvent->getImages()->toArray();
635
        $translatedImagesList = array_filter(
636
            $this->images->toArray(),
637
            function (Image $image) {
638
                return $image->getLanguage()->getCode() !== 'nl';
639
            }
640
        );
641
642
        $imagesList = array_merge($dutchImagesList, $translatedImagesList);
643
        $images = ImageCollection::fromArray($imagesList);
644
645
        $this->images = isset($newMainImage) ? $images->withMain($newMainImage) : $images;
646
    }
647
648
    /**
649
     * @param Label $label
650
     * @return AbstractLabelAdded
651
     */
652
    abstract protected function createLabelAddedEvent(Label $label);
653
654
    /**
655
     * @param Label $label
656
     * @return AbstractLabelRemoved
657
     */
658
    abstract protected function createLabelRemovedEvent(Label $label);
659
660
    /**
661
     * @param Language $language
662
     * @param StringLiteral $title
663
     * @return AbstractTitleTranslated
664
     */
665
    abstract protected function createTitleTranslatedEvent(Language $language, StringLiteral $title);
666
667
    /**
668
     * @param Language $language
669
     * @param StringLiteral $description
670
     * @return AbstractDescriptionTranslated
671
     */
672
    abstract protected function createDescriptionTranslatedEvent(Language $language, StringLiteral $description);
673
674
    /**
675
     * @param Image $image
676
     * @return AbstractImageAdded
677
     */
678
    abstract protected function createImageAddedEvent(Image $image);
679
680
    /**
681
     * @param Image $image
682
     * @return AbstractImageRemoved
683
     */
684
    abstract protected function createImageRemovedEvent(Image $image);
685
686
    /**
687
     * @param AbstractUpdateImage $updateImageCommand
688
     * @return AbstractImageUpdated
689
     */
690
    abstract protected function createImageUpdatedEvent(
691
        AbstractUpdateImage $updateImageCommand
692
    );
693
694
    /**
695
     * @param Image $image
696
     * @return AbstractMainImageSelected
697
     */
698
    abstract protected function createMainImageSelectedEvent(Image $image);
699
700
    /**
701
     * @return AbstractOfferDeleted
702
     */
703
    abstract protected function createOfferDeletedEvent();
704
705
    /**
706
     * @param Title $title
707
     * @return AbstractTitleUpdated
708
     */
709
    abstract protected function createTitleUpdatedEvent(Title $title);
710
711
    /**
712
     * @param string $description
713
     * @return AbstractDescriptionUpdated
714
     */
715
    abstract protected function createDescriptionUpdatedEvent($description);
716
717
    /**
718
     * @param Calendar $calendar
719
     * @return AbstractCalendarUpdated
720
     */
721
    abstract protected function createCalendarUpdatedEvent(Calendar $calendar);
722
723
    /**
724
     * @param string $typicalAgeRange
725
     * @return AbstractTypicalAgeRangeUpdated
726
     */
727
    abstract protected function createTypicalAgeRangeUpdatedEvent($typicalAgeRange);
728
729
    /**
730
     * @return AbstractTypicalAgeRangeDeleted
731
     */
732
    abstract protected function createTypicalAgeRangeDeletedEvent();
733
734
    /**
735
     * @param string $organizerId
736
     * @return AbstractOrganizerUpdated
737
     */
738
    abstract protected function createOrganizerUpdatedEvent($organizerId);
739
740
    /**
741
     * @param string $organizerId
742
     * @return AbstractOrganizerDeleted
743
     */
744
    abstract protected function createOrganizerDeletedEvent($organizerId);
745
746
    /**
747
     * @param ContactPoint $contactPoint
748
     * @return AbstractContactPointUpdated
749
     */
750
    abstract protected function createContactPointUpdatedEvent(ContactPoint $contactPoint);
751
752
    /**
753
     * @param BookingInfo $bookingInfo
754
     * @return AbstractBookingInfoUpdated
755
     */
756
    abstract protected function createBookingInfoUpdatedEvent(BookingInfo $bookingInfo);
757
758
    /**
759
     * @param PriceInfo $priceInfo
760
     * @return AbstractPriceInfoUpdated
761
     */
762
    abstract protected function createPriceInfoUpdatedEvent(PriceInfo $priceInfo);
763
764
    /**
765
     * @param \DateTimeInterface $publicationDate
766
     * @return AbstractPublished
767
     */
768
    abstract protected function createPublishedEvent(\DateTimeInterface $publicationDate);
769
770
    /**
771
     * @return AbstractApproved
772
     */
773
    abstract protected function createApprovedEvent();
774
775
    /**
776
     * @param StringLiteral $reason
777
     * @return AbstractRejected
778
     */
779
    abstract protected function createRejectedEvent(StringLiteral $reason);
780
781
    /**
782
     * @return AbstractFlaggedAsDuplicate
783
     */
784
    abstract protected function createFlaggedAsDuplicate();
785
786
    /**
787
     * @return AbstractFlaggedAsInappropriate
788
     */
789
    abstract protected function createFlaggedAsInappropriate();
790
791
    /**
792
     * @param ImageCollection $images
793
     * @return AbstractImagesImportedFromUDB2
794
     */
795
    abstract protected function createImagesImportedFromUDB2(ImageCollection $images);
796
797
    /**
798
     * @param ImageCollection $images
799
     * @return AbstractImagesUpdatedFromUDB2
800
     */
801
    abstract protected function createImagesUpdatedFromUDB2(ImageCollection $images);
802
}
803