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

Offer::isTitleChanged()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Importance

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