Completed
Pull Request — master (#321)
by
unknown
04:23
created

Offer::createOrganizerDeletedEvent()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 1
nc 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\ContactPoint;
9
use CultuurNet\UDB3\Description;
10
use CultuurNet\UDB3\Label;
11
use CultuurNet\UDB3\LabelAwareAggregateRoot;
12
use CultuurNet\UDB3\LabelCollection;
13
use CultuurNet\UDB3\Media\Image;
14
use CultuurNet\UDB3\Media\ImageCollection;
15
use CultuurNet\UDB3\Offer\Commands\Image\AbstractUpdateImage;
16
use CultuurNet\UDB3\Language;
17
use CultuurNet\UDB3\Offer\Events\AbstractBookingInfoUpdated;
18
use CultuurNet\UDB3\Offer\Events\AbstractContactPointUpdated;
19
use CultuurNet\UDB3\Offer\Events\AbstractTitleTranslated;
20
use CultuurNet\UDB3\Offer\Events\AbstractTitleUpdated;
21
use CultuurNet\UDB3\Offer\Events\AbstractDescriptionTranslated;
22
use CultuurNet\UDB3\Offer\Events\AbstractDescriptionUpdated;
23
use CultuurNet\UDB3\Offer\Events\AbstractLabelAdded;
24
use CultuurNet\UDB3\Offer\Events\AbstractLabelRemoved;
25
use CultuurNet\UDB3\Offer\Events\AbstractOfferDeleted;
26
use CultuurNet\UDB3\Offer\Events\AbstractOrganizerDeleted;
27
use CultuurNet\UDB3\Offer\Events\AbstractOrganizerUpdated;
28
use CultuurNet\UDB3\Offer\Events\AbstractPriceInfoUpdated;
29
use CultuurNet\UDB3\Offer\Events\AbstractTypicalAgeRangeDeleted;
30
use CultuurNet\UDB3\Offer\Events\AbstractTypicalAgeRangeUpdated;
31
use CultuurNet\UDB3\Offer\Events\Image\AbstractImageAdded;
32
use CultuurNet\UDB3\Offer\Events\Image\AbstractImageRemoved;
33
use CultuurNet\UDB3\Offer\Events\Image\AbstractImagesEvent;
34
use CultuurNet\UDB3\Offer\Events\Image\AbstractImagesImportedFromUDB2;
35
use CultuurNet\UDB3\Offer\Events\Image\AbstractImagesUpdatedFromUDB2;
36
use CultuurNet\UDB3\Offer\Events\Image\AbstractImageUpdated;
37
use CultuurNet\UDB3\Offer\Events\Image\AbstractMainImageSelected;
38
use CultuurNet\UDB3\Offer\Events\Moderation\AbstractApproved;
39
use CultuurNet\UDB3\Offer\Events\Moderation\AbstractFlaggedAsDuplicate;
40
use CultuurNet\UDB3\Offer\Events\Moderation\AbstractFlaggedAsInappropriate;
41
use CultuurNet\UDB3\Offer\Events\Moderation\AbstractPublished;
42
use CultuurNet\UDB3\Offer\Events\Moderation\AbstractRejected;
43
use CultuurNet\UDB3\PriceInfo\PriceInfo;
44
use Exception;
45
use ValueObjects\Identity\UUID;
46
use ValueObjects\StringLiteral\StringLiteral;
47
48
abstract class Offer extends EventSourcedAggregateRoot implements LabelAwareAggregateRoot
49
{
50
    const DUPLICATE_REASON = 'duplicate';
51
    const INAPPROPRIATE_REASON = 'inappropriate';
52
53
    /**
54
     * @var LabelCollection
55
     */
56
    protected $labels;
57
58
    /**
59
     * @var ImageCollection
60
     */
61
    protected $images;
62
63
    /**
64
     * @var string
65
     *
66
     * Organizer ids can come from UDB2 which does not strictly use UUIDs.
67
     */
68
    protected $organizerId;
69
70
    /**
71
     * @var WorkflowStatus
72
     */
73
    protected $workflowStatus;
74
75
    /**
76
     * @var StringLiteral|null
77
     */
78
    protected $rejectedReason;
79
80
    /**
81
     * @var PriceInfo
82
     */
83
    protected $priceInfo;
84
85
    /**
86
     * @var StringLiteral[]
87
     */
88
    protected $titles;
89
90
    /**
91
     * @var Description[]
92
     */
93
    protected $descriptions;
94
95
    /**
96
     * @var Language
97
     */
98
    protected $mainLanguage;
99
100
    /**
101
     * Offer constructor.
102
     */
103
    public function __construct()
104
    {
105
        // For now the main language is hard coded on nl.
106
        // In the future it should be set on create.
107
        $this->mainLanguage = new Language('nl');
108
109
        $this->titles = [];
110
        $this->descriptions = [];
111
        $this->labels = new LabelCollection();
112
        $this->images = new ImageCollection();
113
    }
114
115
    /**
116
     * Get the id of the main image if one is selected for this offer.
117
     *
118
     * @return UUID|null
119
     */
120
    protected function getMainImageId()
121
    {
122
        $mainImage = $this->images->getMain();
123
        return isset($mainImage) ? $mainImage->getMediaObjectId() : null;
124
    }
125
126
    /**
127
     * @inheritdoc
128
     */
129
    public function addLabel(Label $label)
130
    {
131
        if (!$this->labels->contains($label)) {
132
            $this->apply(
133
                $this->createLabelAddedEvent($label)
134
            );
135
        }
136
    }
137
138
    /**
139
     * @inheritdoc
140
     */
141
    public function removeLabel(Label $label)
142
    {
143
        if ($this->labels->contains($label)) {
144
            $this->apply(
145
                $this->createLabelRemovedEvent($label)
146
            );
147
        }
148
    }
149
150
    /**
151
     * @param Language $language
152
     * @param StringLiteral $title
153
     */
154
    public function updateTitle(Language $language, StringLiteral $title)
155
    {
156
        if ($this->isTitleChanged($title, $language)) {
157
            if ($language->getCode() !== $this->mainLanguage->getCode()) {
158
                $event = $this->createTitleTranslatedEvent($language, $title);
159
            } else {
160
                $event = $this->createTitleUpdatedEvent((string) $title);
161
            }
162
163
            $this->apply($event);
164
        }
165
    }
166
167
    /**
168
     * @param Description $description
169
     * @param Language $language
170
     */
171
    public function updateDescription(Description $description, Language $language)
172
    {
173
        if ($this->isDescriptionChanged($description, $language)) {
174
            if ($language->getCode() !== $this->mainLanguage->getCode()) {
175
                $event = $this->createDescriptionTranslatedEvent($language, $description);
176
            } else {
177
                $event = $this->createDescriptionUpdatedEvent((string) $description);
178
            }
179
180
            $this->apply($event);
181
        }
182
    }
183
184
    /**
185
     * @param string $typicalAgeRange
186
     */
187
    public function updateTypicalAgeRange($typicalAgeRange)
188
    {
189
        $this->apply(
190
            $this->createTypicalAgeRangeUpdatedEvent($typicalAgeRange)
191
        );
192
    }
193
194
    public function deleteTypicalAgeRange()
195
    {
196
        $this->apply(
197
            $this->createTypicalAgeRangeDeletedEvent()
198
        );
199
    }
200
201
    /**
202
     * @param string $organizerId
203
     */
204
    public function updateOrganizer($organizerId)
205
    {
206
        if ($this->organizerId !== $organizerId) {
207
            $this->apply(
208
                $this->createOrganizerUpdatedEvent($organizerId)
209
            );
210
        }
211
    }
212
213
    /**
214
     * Delete the given organizer.
215
     *
216
     * @param string $organizerId
217
     */
218
    public function deleteOrganizer($organizerId)
219
    {
220
        if ($this->organizerId === $organizerId) {
221
            $this->apply(
222
                $this->createOrganizerDeletedEvent($organizerId)
223
            );
224
        }
225
    }
226
227
    /**
228
     * Updated the contact info.
229
     * @param ContactPoint $contactPoint
230
     */
231
    public function updateContactPoint(ContactPoint $contactPoint)
232
    {
233
        $this->apply(
234
            $this->createContactPointUpdatedEvent($contactPoint)
235
        );
236
    }
237
238
    /**
239
     * Updated the booking info.
240
     *
241
     * @param BookingInfo $bookingInfo
242
     */
243
    public function updateBookingInfo(BookingInfo $bookingInfo)
244
    {
245
        $this->apply(
246
            $this->createBookingInfoUpdatedEvent($bookingInfo)
247
        );
248
    }
249
250
    /**
251
     * @param PriceInfo $priceInfo
252
     */
253
    public function updatePriceInfo(PriceInfo $priceInfo)
254
    {
255
        if (is_null($this->priceInfo) || $priceInfo->serialize() !== $this->priceInfo->serialize()) {
256
            $this->apply(
257
                $this->createPriceInfoUpdatedEvent($priceInfo)
258
            );
259
        }
260
    }
261
262
    /**
263
     * @param AbstractPriceInfoUpdated $priceInfoUpdated
264
     */
265
    protected function applyPriceInfoUpdated(AbstractPriceInfoUpdated $priceInfoUpdated)
266
    {
267
        $this->priceInfo = $priceInfoUpdated->getPriceInfo();
268
    }
269
270
    /**
271
     * @param AbstractLabelAdded $labelAdded
272
     */
273
    protected function applyLabelAdded(AbstractLabelAdded $labelAdded)
274
    {
275
        $this->labels = $this->labels->with($labelAdded->getLabel());
276
    }
277
278
    /**
279
     * @param AbstractLabelRemoved $labelRemoved
280
     */
281
    protected function applyLabelRemoved(AbstractLabelRemoved $labelRemoved)
282
    {
283
        $this->labels = $this->labels->without($labelRemoved->getLabel());
284
    }
285
286
    protected function applyDescriptionUpdated(AbstractDescriptionUpdated $descriptionUpdated)
287
    {
288
        $mainLanguageCode = $this->mainLanguage->getCode();
289
        $this->descriptions[$mainLanguageCode] = new Description($descriptionUpdated->getDescription());
290
    }
291
292
    protected function applyDescriptionTranslated(AbstractDescriptionTranslated $descriptionTranslated)
293
    {
294
        $languageCode = $descriptionTranslated->getLanguage()->getCode();
295
        $this->descriptions[$languageCode] = $descriptionTranslated->getDescription();
296
    }
297
298
    /**
299
     * Add a new image.
300
     *
301
     * @param Image $image
302
     */
303
    public function addImage(Image $image)
304
    {
305
        if (!$this->images->contains($image)) {
306
            $this->apply(
307
                $this->createImageAddedEvent($image)
308
            );
309
        }
310
    }
311
312
    /**
313
     * @param AbstractUpdateImage $updateImageCommand
314
     */
315
    public function updateImage(AbstractUpdateImage $updateImageCommand)
316
    {
317
        if ($this->images->findImageByUUID($updateImageCommand->getMediaObjectId())) {
318
            $this->apply(
319
                $this->createImageUpdatedEvent($updateImageCommand)
320
            );
321
        }
322
    }
323
324
    /**
325
     * Remove an image.
326
     *
327
     * @param Image $image
328
     */
329
    public function removeImage(Image $image)
330
    {
331
        if ($this->images->contains($image)) {
332
            $this->apply(
333
                $this->createImageRemovedEvent($image)
334
            );
335
        }
336
    }
337
338
    /**
339
     * Make an existing image of the item the main image.
340
     *
341
     * @param Image $image
342
     */
343
    public function selectMainImage(Image $image)
344
    {
345
        if (!$this->images->contains($image)) {
346
            throw new \InvalidArgumentException('You can not select a random image to be main, it has to be added to the item.');
347
        }
348
349
        $oldMainImage = $this->images->getMain();
350
351
        if (!isset($oldMainImage) || $oldMainImage->getMediaObjectId() !== $image->getMediaObjectId()) {
352
            $this->apply(
353
                $this->createMainImageSelectedEvent($image)
354
            );
355
        }
356
    }
357
358
    /**
359
     * Delete the offer.
360
     */
361
    public function delete()
362
    {
363
        $this->apply(
364
            $this->createOfferDeletedEvent()
365
        );
366
    }
367
368
    /**
369
     * @param CultureFeed_Cdb_Item_Base $cdbItem
370
     */
371
    protected function importWorkflowStatus(CultureFeed_Cdb_Item_Base $cdbItem)
372
    {
373
        try {
374
            $workflowStatus = WorkflowStatus::fromNative($cdbItem->getWfStatus());
375
        } catch (\InvalidArgumentException $exception) {
376
            $workflowStatus = WorkflowStatus::READY_FOR_VALIDATION();
377
        }
378
        $this->workflowStatus = $workflowStatus;
379
    }
380
381
    /**
382
     * Publish the offer when it has workflowstatus draft.
383
     * @param \DateTimeInterface $publicationDate
384
     */
385
    public function publish(\DateTimeInterface $publicationDate)
386
    {
387
        $this->guardPublish() ?: $this->apply(
388
            $this->createPublishedEvent($publicationDate)
389
        );
390
    }
391
392
    /**
393
     * @return bool
394
     * @throws Exception
395
     */
396 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...
397
    {
398
        if ($this->workflowStatus === WorkflowStatus::READY_FOR_VALIDATION()) {
399
            return true; // nothing left to do if the offer has already been published
400
        }
401
402
        if ($this->workflowStatus !== WorkflowStatus::DRAFT()) {
403
            throw new Exception('You can not publish an offer that is not draft');
404
        }
405
406
        return false;
407
    }
408
409
    /**
410
     * Approve the offer when it's waiting for validation.
411
     */
412
    public function approve()
413
    {
414
        $this->guardApprove() ?: $this->apply($this->createApprovedEvent());
415
    }
416
417
    /**
418
     * @return bool
419
     * @throws Exception
420
     */
421 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...
422
    {
423
        if ($this->workflowStatus === WorkflowStatus::APPROVED()) {
424
            return true; // nothing left to do if the offer has already been approved
425
        }
426
427
        if ($this->workflowStatus !== WorkflowStatus::READY_FOR_VALIDATION()) {
428
            throw new Exception('You can not approve an offer that is not ready for validation');
429
        }
430
431
        return false;
432
    }
433
434
    /**
435
     * Reject an offer that is waiting for validation with a given reason.
436
     * @param StringLiteral $reason
437
     */
438
    public function reject(StringLiteral $reason)
439
    {
440
        $this->guardRejection($reason) ?: $this->apply($this->createRejectedEvent($reason));
441
    }
442
443
    public function flagAsDuplicate()
444
    {
445
        $reason = new StringLiteral(self::DUPLICATE_REASON);
446
        $this->guardRejection($reason) ?: $this->apply($this->createFlaggedAsDuplicate());
447
    }
448
449
    public function flagAsInappropriate()
450
    {
451
        $reason = new StringLiteral(self::INAPPROPRIATE_REASON);
452
        $this->guardRejection($reason) ?: $this->apply($this->createFlaggedAsInappropriate());
453
    }
454
455
    /**
456
     * @param StringLiteral $reason
457
     * @return bool
458
     *  false when the offer can still be rejected, true when the offer is already rejected for the same reason
459
     * @throws Exception
460
     */
461
    private function guardRejection(StringLiteral $reason)
462
    {
463
        if ($this->workflowStatus === WorkflowStatus::REJECTED()) {
464
            if ($this->rejectedReason && $reason->sameValueAs($this->rejectedReason)) {
465
                return true; // nothing left to do if the offer has already been rejected for the same reason
466
            } else {
467
                throw new Exception('The offer has already been rejected for another reason: ' . $this->rejectedReason);
468
            }
469
        }
470
471
        if ($this->workflowStatus !== WorkflowStatus::READY_FOR_VALIDATION()) {
472
            throw new Exception('You can not reject an offer that is not ready for validation');
473
        }
474
475
        return false;
476
    }
477
478
    /**
479
     * @param StringLiteral $title
480
     * @param Language $language
481
     * @return bool
482
     */
483 View Code Duplication
    private function isTitleChanged(StringLiteral $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...
484
    {
485
        $languageCode = $language->getCode();
486
487
        return !isset($this->titles[$languageCode]) ||
488
            !$title->sameValueAs($this->titles[$languageCode]);
489
    }
490
491
    /**
492
     * @param Description $description
493
     * @param Language $language
494
     * @return bool
495
     */
496 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...
497
    {
498
        $languageCode = $language->getCode();
499
500
        return !isset($this->descriptions[$languageCode]) ||
501
            !$description->sameValueAs($this->descriptions[$languageCode]);
502
    }
503
504
    /**
505
     * Overwrites or resets the main image and all media objects
506
     * by importing a new collection of images from UDB2.
507
     *
508
     * @param ImageCollection $images
509
     */
510
    public function importImagesFromUDB2(ImageCollection $images)
511
    {
512
        $this->apply($this->createImagesImportedFromUDB2($images));
513
    }
514
515
    /**
516
     * Overwrites or resets the main image and all media objects
517
     * by updating with a new collection of images from UDB2.
518
     *
519
     * @param ImageCollection $images
520
     */
521
    public function updateImagesFromUDB2(ImageCollection $images)
522
    {
523
        $this->apply($this->createImagesUpdatedFromUDB2($images));
524
    }
525
526
    /**
527
     * @param AbstractPublished $published
528
     */
529
    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...
530
    {
531
        $this->workflowStatus = WorkflowStatus::READY_FOR_VALIDATION();
532
    }
533
534
    /**
535
     * @param AbstractApproved $approved
536
     */
537
    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...
538
    {
539
        $this->workflowStatus = WorkflowStatus::APPROVED();
540
    }
541
542
    /**
543
     * @param AbstractRejected $rejected
544
     */
545
    protected function applyRejected(AbstractRejected $rejected)
546
    {
547
        $this->rejectedReason = $rejected->getReason();
548
        $this->workflowStatus = WorkflowStatus::REJECTED();
549
    }
550
551
    /**
552
     * @param AbstractFlaggedAsDuplicate $flaggedAsDuplicate
553
     */
554
    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...
555
    {
556
        $this->rejectedReason = new StringLiteral(self::DUPLICATE_REASON);
557
        $this->workflowStatus = WorkflowStatus::REJECTED();
558
    }
559
560
    /**
561
     * @param AbstractFlaggedAsInappropriate $flaggedAsInappropriate
562
     */
563
    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...
564
    {
565
        $this->rejectedReason = new StringLiteral(self::INAPPROPRIATE_REASON);
566
        $this->workflowStatus = WorkflowStatus::REJECTED();
567
    }
568
569
    protected function applyImageAdded(AbstractImageAdded $imageAdded)
570
    {
571
        $this->images = $this->images->with($imageAdded->getImage());
572
    }
573
574
    protected function applyImageRemoved(AbstractImageRemoved $imageRemoved)
575
    {
576
        $this->images = $this->images->without($imageRemoved->getImage());
577
    }
578
579
    protected function applyMainImageSelected(AbstractMainImageSelected $mainImageSelected)
580
    {
581
        $this->images = $this->images->withMain($mainImageSelected->getImage());
582
    }
583
584
    protected function applyOrganizerUpdated(AbstractOrganizerUpdated $organizerUpdated)
585
    {
586
        $this->organizerId = $organizerUpdated->getOrganizerId();
587
    }
588
589
    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...
590
    {
591
        $this->organizerId = null;
592
    }
593
594
    /**
595
     * @param AbstractImagesImportedFromUDB2 $imagesImportedFromUDB2
596
     */
597
    protected function applyImagesImportedFromUDB2(AbstractImagesImportedFromUDB2 $imagesImportedFromUDB2)
598
    {
599
        $this->applyUdb2ImagesEvent($imagesImportedFromUDB2);
600
    }
601
602
    /**
603
     * @param AbstractImagesUpdatedFromUDB2 $imagesUpdatedFromUDB2
604
     */
605
    protected function applyImagesUpdatedFromUDB2(AbstractImagesUpdatedFromUDB2 $imagesUpdatedFromUDB2)
606
    {
607
        $this->applyUdb2ImagesEvent($imagesUpdatedFromUDB2);
608
    }
609
610
    /**
611
     * This indirect apply method can be called internally to deal with images coming from UDB2.
612
     * Imports from UDB2 only contain the native Dutch content.
613
     * @see https://github.com/cultuurnet/udb3-udb2-bridge/blob/db0a7ab2444f55bb3faae3d59b82b39aaeba253b/test/Media/ImageCollectionFactoryTest.php#L79-L103
614
     * Because of this we have to make sure translated images are left in place.
615
     *
616
     * @param AbstractImagesEvent $imagesEvent
617
     */
618
    protected function applyUdb2ImagesEvent(AbstractImagesEvent $imagesEvent)
619
    {
620
        $newMainImage = $imagesEvent->getImages()->getMain();
621
        $dutchImagesList = $imagesEvent->getImages()->toArray();
622
        $translatedImagesList = array_filter(
623
            $this->images->toArray(),
624
            function (Image $image) {
625
                return $image->getLanguage()->getCode() !== 'nl';
626
            }
627
        );
628
629
        $imagesList = array_merge($dutchImagesList, $translatedImagesList);
630
        $images = ImageCollection::fromArray($imagesList);
631
632
        $this->images = isset($newMainImage) ? $images->withMain($newMainImage) : $images;
633
    }
634
635
    /**
636
     * @param Label $label
637
     * @return AbstractLabelAdded
638
     */
639
    abstract protected function createLabelAddedEvent(Label $label);
640
641
    /**
642
     * @param Label $label
643
     * @return AbstractLabelRemoved
644
     */
645
    abstract protected function createLabelRemovedEvent(Label $label);
646
647
    /**
648
     * @param Language $language
649
     * @param StringLiteral $title
650
     * @return AbstractTitleTranslated
651
     */
652
    abstract protected function createTitleTranslatedEvent(Language $language, StringLiteral $title);
653
654
    /**
655
     * @param Language $language
656
     * @param StringLiteral $description
657
     * @return AbstractDescriptionTranslated
658
     */
659
    abstract protected function createDescriptionTranslatedEvent(Language $language, StringLiteral $description);
660
661
    /**
662
     * @param Image $image
663
     * @return AbstractImageAdded
664
     */
665
    abstract protected function createImageAddedEvent(Image $image);
666
667
    /**
668
     * @param Image $image
669
     * @return AbstractImageRemoved
670
     */
671
    abstract protected function createImageRemovedEvent(Image $image);
672
673
    /**
674
     * @param AbstractUpdateImage $updateImageCommand
675
     * @return AbstractImageUpdated
676
     */
677
    abstract protected function createImageUpdatedEvent(
678
        AbstractUpdateImage $updateImageCommand
679
    );
680
681
    /**
682
     * @param Image $image
683
     * @return AbstractMainImageSelected
684
     */
685
    abstract protected function createMainImageSelectedEvent(Image $image);
686
687
    /**
688
     * @return AbstractOfferDeleted
689
     */
690
    abstract protected function createOfferDeletedEvent();
691
692
    /**
693
     * @param string $title
694
     * @return AbstractTitleUpdated
695
     */
696
    abstract protected function createTitleUpdatedEvent($title);
697
698
    /**
699
     * @param string $description
700
     * @return AbstractDescriptionUpdated
701
     */
702
    abstract protected function createDescriptionUpdatedEvent($description);
703
704
    /**
705
     * @param string $typicalAgeRange
706
     * @return AbstractTypicalAgeRangeUpdated
707
     */
708
    abstract protected function createTypicalAgeRangeUpdatedEvent($typicalAgeRange);
709
710
    /**
711
     * @return AbstractTypicalAgeRangeDeleted
712
     */
713
    abstract protected function createTypicalAgeRangeDeletedEvent();
714
715
    /**
716
     * @param string $organizerId
717
     * @return AbstractOrganizerUpdated
718
     */
719
    abstract protected function createOrganizerUpdatedEvent($organizerId);
720
721
    /**
722
     * @param string $organizerId
723
     * @return AbstractOrganizerDeleted
724
     */
725
    abstract protected function createOrganizerDeletedEvent($organizerId);
726
727
    /**
728
     * @param ContactPoint $contactPoint
729
     * @return AbstractContactPointUpdated
730
     */
731
    abstract protected function createContactPointUpdatedEvent(ContactPoint $contactPoint);
732
733
    /**
734
     * @param BookingInfo $bookingInfo
735
     * @return AbstractBookingInfoUpdated
736
     */
737
    abstract protected function createBookingInfoUpdatedEvent(BookingInfo $bookingInfo);
738
739
    /**
740
     * @param PriceInfo $priceInfo
741
     * @return AbstractPriceInfoUpdated
742
     */
743
    abstract protected function createPriceInfoUpdatedEvent(PriceInfo $priceInfo);
744
745
    /**
746
     * @param \DateTimeInterface $publicationDate
747
     * @return AbstractPublished
748
     */
749
    abstract protected function createPublishedEvent(\DateTimeInterface $publicationDate);
750
751
    /**
752
     * @return AbstractApproved
753
     */
754
    abstract protected function createApprovedEvent();
755
756
    /**
757
     * @param StringLiteral $reason
758
     * @return AbstractRejected
759
     */
760
    abstract protected function createRejectedEvent(StringLiteral $reason);
761
762
    /**
763
     * @return AbstractFlaggedAsDuplicate
764
     */
765
    abstract protected function createFlaggedAsDuplicate();
766
767
    /**
768
     * @return AbstractFlaggedAsInappropriate
769
     */
770
    abstract protected function createFlaggedAsInappropriate();
771
772
    /**
773
     * @param ImageCollection $images
774
     * @return AbstractImagesImportedFromUDB2
775
     */
776
    abstract protected function createImagesImportedFromUDB2(ImageCollection $images);
777
778
    /**
779
     * @param ImageCollection $images
780
     * @return AbstractImagesUpdatedFromUDB2
781
     */
782
    abstract protected function createImagesUpdatedFromUDB2(ImageCollection $images);
783
}
784