Passed
Push — typo3_11 ( 8ab83f...efeb95 )
by Torben
04:32
created

Event::getCustomText()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Extension "sf_event_mgt" for TYPO3 CMS.
7
 *
8
 * For the full copyright and license information, please read the
9
 * LICENSE.txt file that was distributed with this source code.
10
 */
11
12
namespace DERHANSEN\SfEventMgt\Domain\Model;
13
14
use DateTime;
15
use DERHANSEN\SfEventMgt\Domain\Model\Registration\Field;
16
use DERHANSEN\SfEventMgt\Domain\Repository\RegistrationRepository;
17
use DERHANSEN\SfEventMgt\Utility\MiscUtility;
18
use DERHANSEN\SfEventMgt\Utility\ShowInPreviews;
19
use TYPO3\CMS\Core\Context\Context;
20
use TYPO3\CMS\Extbase\Domain\Model\FileReference;
21
use TYPO3\CMS\Core\Utility\GeneralUtility;
22
use TYPO3\CMS\Extbase\Annotation as Extbase;
23
use TYPO3\CMS\Extbase\DomainObject\AbstractEntity;
24
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
25
26
/**
27
 * Event
28
 */
29
class Event extends AbstractEntity
30
{
31
    protected ?DateTime $tstamp = null;
32
    protected bool $hidden = false;
33
    protected ?DateTime $starttime = null;
34
    protected ?DateTime $endtime = null;
35
    protected string $title = '';
36
    protected string $teaser = '';
37
    protected string $description = '';
38
    protected string $program = '';
39
    protected string $customText = '';
40
    protected ?DateTime $startdate = null;
41
    protected ?DateTime $enddate = null;
42
    protected int $maxParticipants = 0;
43
    protected int $maxRegistrationsPerUser = 1;
44
    protected float $price = 0.0;
45
    protected string $currency = '';
46
    protected bool $enablePayment = false;
47
    protected bool $restrictPaymentMethods = false;
48
    protected string $selectedPaymentMethods = '';
49
    protected ?DateTime $registrationStartdate = null;
50
    protected ?DateTime $registrationDeadline = null;
51
    protected ?Location $location = null;
52
    protected string $room = '';
53
    protected bool $enableRegistration = false;
54
    protected bool $enableWaitlist = false;
55
    protected bool $enableWaitlistMoveup = false;
56
    protected string $link = '';
57
    protected bool $topEvent = false;
58
    protected ?Organisator $organisator = null;
59
    protected bool $notifyAdmin = true;
60
    protected bool $notifyOrganisator = false;
61
    protected bool $enableCancel = false;
62
    protected ?DateTime $cancelDeadline = null;
63
    protected bool $enableAutoconfirm = false;
64
    protected bool $uniqueEmailCheck = false;
65
66
    /**
67
     * @var ObjectStorage<Category>
68
     * @Extbase\ORM\Lazy
69
     */
70
    protected ObjectStorage $category;
71
72
    /**
73
     * @var ObjectStorage<Event>
74
     * @Extbase\ORM\Lazy
75
     */
76
    protected ObjectStorage $related;
77
78
    /**
79
     * @var ObjectStorage<Registration>
80
     * @Extbase\ORM\Cascade("remove")
81
     * @Extbase\ORM\Lazy
82
     */
83
    protected ObjectStorage $registration;
84
85
    /**
86
     * @var ObjectStorage<Registration>
87
     * @Extbase\ORM\Lazy
88
     */
89
    protected ObjectStorage $registrationWaitlist;
90
91
    /**
92
     * @var ObjectStorage<Field>
93
     * @Extbase\ORM\Lazy
94
     */
95
    protected ObjectStorage $registrationFields;
96
97
    /**
98
     * @var ObjectStorage<FileReference>
99
     * @Extbase\ORM\Lazy
100
     */
101
    protected ObjectStorage $image;
102
103
    /**
104
     * @var ObjectStorage<FileReference>
105
     * @Extbase\ORM\Lazy
106
     */
107
    protected ObjectStorage $files;
108
109
    /**
110
     * @var ObjectStorage<FileReference>
111
     * @Extbase\ORM\Lazy
112
     */
113
    protected ObjectStorage $additionalImage;
114
115
    /**
116
     * @var ObjectStorage<PriceOption>
117
     * @Extbase\ORM\Cascade("remove")
118
     * @Extbase\ORM\Lazy
119
     */
120
    protected ObjectStorage $priceOptions;
121
122
    /**
123
     * @var ObjectStorage<Speaker>
124
     * @Extbase\ORM\Lazy
125
     */
126
    protected ObjectStorage $speaker;
127
128
    public function __construct()
129
    {
130
        $this->initializeObject();
131
    }
132
133
    /**
134
     * Initialize all ObjectStorages as fetching an entity from the DB does not use the constructor
135
     */
136
    public function initializeObject()
137
    {
138
        $this->category = new ObjectStorage();
139
        $this->related = new ObjectStorage();
140
        $this->registration = new ObjectStorage();
141
        $this->registrationWaitlist = new ObjectStorage();
142
        $this->registrationFields = new ObjectStorage();
143
        $this->image = new ObjectStorage();
144
        $this->files = new ObjectStorage();
145
        $this->additionalImage = new ObjectStorage();
146
        $this->priceOptions = new ObjectStorage();
147
        $this->speaker = new ObjectStorage();
148
    }
149
150
    public function getTstamp(): ?DateTime
151
    {
152
        return $this->tstamp;
153
    }
154
155
    public function setTstamp(?DateTime $tstamp)
156
    {
157
        $this->tstamp = $tstamp;
158
    }
159
160
    public function getHidden(): bool
161
    {
162
        return $this->hidden;
163
    }
164
165
    public function setHidden(bool $hidden)
166
    {
167
        $this->hidden = $hidden;
168
    }
169
170
    public function getStarttime(): ?DateTime
171
    {
172
        return $this->starttime;
173
    }
174
175
    public function setStarttime(?DateTime $starttime)
176
    {
177
        $this->starttime = $starttime;
178
    }
179
180
    public function getEndtime(): ?DateTime
181
    {
182
        return $this->endtime;
183
    }
184
185
    public function setEndtime(?DateTime $endtime)
186
    {
187
        $this->endtime = $endtime;
188
    }
189
190
    public function getTitle(): string
191
    {
192
        return $this->title;
193
    }
194
195
    public function setTitle(string $title)
196
    {
197
        $this->title = $title;
198
    }
199
200
    public function getTeaser(): string
201
    {
202
        return $this->teaser;
203
    }
204
205
    public function setTeaser(string $teaser)
206
    {
207
        $this->teaser = $teaser;
208
    }
209
210
    public function getDescription(): string
211
    {
212
        return $this->description;
213
    }
214
215
    public function setDescription(string $description)
216
    {
217
        $this->description = $description;
218
    }
219
220
    public function getProgram(): string
221
    {
222
        return $this->program;
223
    }
224
225
    public function setProgram(string $program)
226
    {
227
        $this->program = $program;
228
    }
229
230
    public function getCustomText(): string
231
    {
232
        return $this->customText;
233
    }
234
235
    public function setCustomText(string $customText): void
236
    {
237
        $this->customText = $customText;
238
    }
239
240
241
    public function getStartdate(): ?DateTime
242
    {
243
        return $this->startdate;
244
    }
245
246
    public function setStartdate(?DateTime $startdate)
247
    {
248
        $this->startdate = $startdate;
249
    }
250
251
    public function getEnddate(): ?DateTime
252
    {
253
        return $this->enddate;
254
    }
255
256
    public function setEnddate(?DateTime $enddate)
257
    {
258
        $this->enddate = $enddate;
259
    }
260
261
    public function getMaxParticipants(): int
262
    {
263
        return $this->maxParticipants;
264
    }
265
266
    public function setMaxParticipants(int $participants)
267
    {
268
        $this->maxParticipants = $participants;
269
    }
270
271
    public function getPrice(): float
272
    {
273
        return $this->price;
274
    }
275
276
    public function setPrice(float $price)
277
    {
278
        $this->price = $price;
279
    }
280
281
    public function getCurrency(): string
282
    {
283
        return $this->currency;
284
    }
285
286
    public function setCurrency(string $currency)
287
    {
288
        $this->currency = $currency;
289
    }
290
291
    public function getEnablePayment(): bool
292
    {
293
        return $this->enablePayment;
294
    }
295
296
    public function setEnablePayment(bool $enablePayment)
297
    {
298
        $this->enablePayment = $enablePayment;
299
    }
300
301
    public function getRestrictPaymentMethods(): bool
302
    {
303
        return $this->restrictPaymentMethods;
304
    }
305
306
    public function setRestrictPaymentMethods(bool $restrictPaymentMethods)
307
    {
308
        $this->restrictPaymentMethods = $restrictPaymentMethods;
309
    }
310
311
    public function getSelectedPaymentMethods(): string
312
    {
313
        return $this->selectedPaymentMethods;
314
    }
315
316
    public function setSelectedPaymentMethods(string $selectedPaymentMethods)
317
    {
318
        $this->selectedPaymentMethods = $selectedPaymentMethods;
319
    }
320
321
    public function addCategory(Category $category)
322
    {
323
        $this->category->attach($category);
324
    }
325
326
    public function removeCategory(Category $categoryToRemove)
327
    {
328
        $this->category->detach($categoryToRemove);
329
    }
330
331
    public function getCategory(): ?ObjectStorage
332
    {
333
        return $this->category;
334
    }
335
336
    public function setCategory(?ObjectStorage $category)
337
    {
338
        $this->category = $category;
339
    }
340
341
    public function getRelated(): ?ObjectStorage
342
    {
343
        return $this->related;
344
    }
345
346
    public function setRelated(?ObjectStorage $related)
347
    {
348
        $this->related = $related;
349
    }
350
351
    public function addRelated(Event $event)
352
    {
353
        $this->related->attach($event);
354
    }
355
356
    public function removeRelated(Event $event)
357
    {
358
        $this->related->detach($event);
359
    }
360
361
    public function addRegistration(Registration $registration)
362
    {
363
        $this->registration->attach($registration);
364
    }
365
366
    public function removeRegistration(Registration $registrationToRemove)
367
    {
368
        $this->registration->detach($registrationToRemove);
369
    }
370
371
    public function getRegistration(): ?ObjectStorage
372
    {
373
        return $this->registration;
374
    }
375
376
    public function setRegistration(?ObjectStorage $registration)
377
    {
378
        $this->registration = $registration;
379
    }
380
381
    public function addImage(FileReference $image)
382
    {
383
        $this->image->attach($image);
384
    }
385
386
    public function removeImage(FileReference $imageToRemove)
387
    {
388
        $this->image->detach($imageToRemove);
389
    }
390
391
    public function getImage(): ?ObjectStorage
392
    {
393
        return $this->image;
394
    }
395
396
    public function getImages(): ?ObjectStorage
397
    {
398
        return $this->image;
399
    }
400
401
    public function getListViewImages(): ?ObjectStorage
402
    {
403
        return $this->getImagesByType(ShowInPreviews::LIST_VIEWS);
404
    }
405
406
    public function getFirstListViewImage(): ?FileReference
407
    {
408
        $images = $this->getImagesByType(ShowInPreviews::LIST_VIEWS);
409
        $image = $images->current();
410
411
        if (is_a($image, FileReference::class)) {
412
            return $image;
413
        }
414
        return null;
415
    }
416
417
    public function getDetailViewImages(): ?ObjectStorage
418
    {
419
        return $this->getImagesByType(ShowInPreviews::DETAIL_VIEWS);
420
    }
421
422
    public function getFirstDetailViewImage(): ?FileReference
423
    {
424
        $images = $this->getImagesByType(ShowInPreviews::DETAIL_VIEWS);
425
        $image = $images->current();
426
427
        if (is_a($image, FileReference::class)) {
428
            return $image;
429
        }
430
        return null;
431
    }
432
433
    protected function getImagesByType(int $type): ?ObjectStorage
434
    {
435
        $result = new ObjectStorage();
436
437
        foreach ($this->image as $image) {
438
            /** @var \TYPO3\CMS\Core\Resource\FileReference $fileReference */
439
            $fileReference = $image->getOriginalResource();
440
            if ($fileReference !== null && $fileReference->hasProperty('show_in_views') &&
441
                in_array($fileReference->getProperty('show_in_views'), [$type, ShowInPreviews::ALL_VIEWS])
442
            ) {
443
                $result->attach($image);
444
            }
445
        }
446
447
        return $result;
448
    }
449
450
    public function setImage(?ObjectStorage $image)
451
    {
452
        $this->image = $image;
453
    }
454
455
    public function addFiles(FileReference $file)
456
    {
457
        $this->files->attach($file);
458
    }
459
460
    public function removeFiles(FileReference $fileToRemove)
461
    {
462
        $this->files->detach($fileToRemove);
463
    }
464
465
    public function getFiles(): ?ObjectStorage
466
    {
467
        return $this->files;
468
    }
469
470
    public function setFiles(?ObjectStorage $files)
471
    {
472
        $this->files = $files;
473
    }
474
475
    /**
476
     * Returns if the registration for this event is logically possible
477
     *
478
     * @return bool
479
     */
480
    public function getRegistrationPossible(): bool
481
    {
482
        $maxParticipantsNotReached = true;
483
        if ($this->getMaxParticipants() > 0 && $this->getRegistrations()->count() >= $this->maxParticipants) {
484
            $maxParticipantsNotReached = false;
485
        }
486
        $deadlineNotReached = true;
487
        if ($this->getRegistrationDeadline() != null && $this->getRegistrationDeadline() <= new DateTime()) {
488
            $deadlineNotReached = false;
489
        }
490
        $registrationStartReached = true;
491
        if ($this->getRegistrationStartdate() != null && $this->getRegistrationStartdate() > new DateTime()) {
492
            $registrationStartReached = false;
493
        }
494
495
        return ($this->getStartdate() > new DateTime()) &&
496
        ($maxParticipantsNotReached || $this->enableWaitlist) &&
497
        $this->getEnableRegistration() && $deadlineNotReached && $registrationStartReached;
498
    }
499
500
    /**
501
     * Returns the amount of free places
502
     *
503
     * @return int
504
     */
505
    public function getFreePlaces(): int
506
    {
507
        return $this->maxParticipants - $this->getRegistrations()->count();
508
    }
509
510
    public function setLocation(?Location $location)
511
    {
512
        $this->location = $location;
513
    }
514
515
    public function getLocation(): ?Location
516
    {
517
        return $this->location;
518
    }
519
520
    public function getRoom(): string
521
    {
522
        return $this->room;
523
    }
524
525
    public function setRoom(string $room)
526
    {
527
        $this->room = $room;
528
    }
529
530
    public function setEnableRegistration(bool $enableRegistration)
531
    {
532
        $this->enableRegistration = $enableRegistration;
533
    }
534
535
    public function getEnableRegistration(): bool
536
    {
537
        return $this->enableRegistration;
538
    }
539
540
    public function getEnableWaitlist(): bool
541
    {
542
        return $this->enableWaitlist;
543
    }
544
545
    public function setEnableWaitlist(bool $enableWaitlist)
546
    {
547
        $this->enableWaitlist = $enableWaitlist;
548
    }
549
550
    public function getEnableWaitlistMoveup(): bool
551
    {
552
        return $this->enableWaitlistMoveup;
553
    }
554
555
    public function setEnableWaitlistMoveup(bool $enableWaitlistMoveup): void
556
    {
557
        $this->enableWaitlistMoveup = $enableWaitlistMoveup;
558
    }
559
560
    public function setRegistrationStartdate(?DateTime $registrationStartdate)
561
    {
562
        $this->registrationStartdate = $registrationStartdate;
563
    }
564
565
    public function getRegistrationStartdate(): ?DateTime
566
    {
567
        return $this->registrationStartdate;
568
    }
569
570
    public function setRegistrationDeadline(?DateTime $registrationDeadline)
571
    {
572
        $this->registrationDeadline = $registrationDeadline;
573
    }
574
575
    public function getRegistrationDeadline(): ?DateTime
576
    {
577
        return $this->registrationDeadline;
578
    }
579
580
    public function setLink(string $link)
581
    {
582
        $this->link = $link;
583
    }
584
585
    public function getLink(): string
586
    {
587
        return $this->link;
588
    }
589
590
    public function setTopEvent(bool $topEvent)
591
    {
592
        $this->topEvent = $topEvent;
593
    }
594
595
    public function getTopEvent(): bool
596
    {
597
        return $this->topEvent;
598
    }
599
600
    public function getMaxRegistrationsPerUser(): int
601
    {
602
        return $this->maxRegistrationsPerUser;
603
    }
604
605
    public function setMaxRegistrationsPerUser(int $maxRegistrationsPerUser)
606
    {
607
        $this->maxRegistrationsPerUser = $maxRegistrationsPerUser;
608
    }
609
610
    public function addAdditionalImage(FileReference $additionalImage)
611
    {
612
        $this->additionalImage->attach($additionalImage);
613
    }
614
615
    public function removeAdditionalImage(FileReference $additionalImageToRemove)
616
    {
617
        $this->additionalImage->detach($additionalImageToRemove);
618
    }
619
620
    public function getAdditionalImage(): ?ObjectStorage
621
    {
622
        return $this->additionalImage;
623
    }
624
625
    public function setAdditionalImage(?ObjectStorage $additionalImage)
626
    {
627
        $this->additionalImage = $additionalImage;
628
    }
629
630
    public function getOrganisator(): ?Organisator
631
    {
632
        return $this->organisator;
633
    }
634
635
    public function setOrganisator(Organisator $organisator)
636
    {
637
        $this->organisator = $organisator;
638
    }
639
640
    public function getNotifyAdmin(): bool
641
    {
642
        return $this->notifyAdmin;
643
    }
644
645
    public function setNotifyAdmin(bool $notifyAdmin)
646
    {
647
        $this->notifyAdmin = $notifyAdmin;
648
    }
649
650
    public function getNotifyOrganisator(): bool
651
    {
652
        return $this->notifyOrganisator;
653
    }
654
655
    public function setNotifyOrganisator(bool $notifyOrganisator)
656
    {
657
        $this->notifyOrganisator = $notifyOrganisator;
658
    }
659
660
    public function setEnableCancel(bool $enableCancel)
661
    {
662
        $this->enableCancel = $enableCancel;
663
    }
664
665
    public function getEnableCancel(): bool
666
    {
667
        return $this->enableCancel;
668
    }
669
670
    public function setCancelDeadline(?DateTime $cancelDeadline)
671
    {
672
        $this->cancelDeadline = $cancelDeadline;
673
    }
674
675
    public function getCancelDeadline(): ?DateTime
676
    {
677
        return $this->cancelDeadline;
678
    }
679
680
    public function getEnableAutoconfirm(): bool
681
    {
682
        return $this->enableAutoconfirm;
683
    }
684
685
    public function setEnableAutoconfirm(bool $enableAutoconfirm)
686
    {
687
        $this->enableAutoconfirm = $enableAutoconfirm;
688
    }
689
690
    public function getUniqueEmailCheck(): bool
691
    {
692
        return $this->uniqueEmailCheck;
693
    }
694
695
    public function setUniqueEmailCheck(bool $uniqueEmailCheck)
696
    {
697
        $this->uniqueEmailCheck = $uniqueEmailCheck;
698
    }
699
700
    public function getPriceOptions(): ?ObjectStorage
701
    {
702
        return $this->priceOptions;
703
    }
704
705
    public function setPriceOptions(?ObjectStorage $priceOptions)
706
    {
707
        $this->priceOptions = $priceOptions;
708
    }
709
710
    public function addPriceOptions(PriceOption $priceOption)
711
    {
712
        $this->priceOptions->attach($priceOption);
713
    }
714
715
    public function removePriceOptions(PriceOption $priceOption)
716
    {
717
        $this->priceOptions->detach($priceOption);
718
    }
719
720
    /**
721
     * Returns all active price options sorted by date ASC
722
     *
723
     * @return array
724
     */
725
    public function getActivePriceOptions(): array
726
    {
727
        $activePriceOptions = [];
728
        if ($this->getPriceOptions()) {
729
            $compareDate = new DateTime('today midnight');
730
            foreach ($this->getPriceOptions() as $priceOption) {
731
                if ($priceOption->getValidUntil() >= $compareDate) {
732
                    $activePriceOptions[$priceOption->getValidUntil()->getTimestamp()] = $priceOption;
733
                }
734
            }
735
        }
736
        ksort($activePriceOptions);
737
738
        return $activePriceOptions;
739
    }
740
741
    /**
742
     * Returns the current price of the event respecting possible price options
743
     *
744
     * @return float
745
     */
746
    public function getCurrentPrice(): float
747
    {
748
        $activePriceOptions = $this->getActivePriceOptions();
749
        if (count($activePriceOptions) >= 1) {
750
            // Sort active price options and return first element
751
            return reset($activePriceOptions)->getPrice();
752
        }
753
        // Just return the price field
754
        return $this->price;
755
    }
756
757
    public function getRegistrationWaitlist(): ?ObjectStorage
758
    {
759
        return $this->registrationWaitlist;
760
    }
761
762
    public function setRegistrationWaitlist(?ObjectStorage $registration)
763
    {
764
        $this->registrationWaitlist = $registration;
765
    }
766
767
    public function addRegistrationWaitlist(Registration $registration)
768
    {
769
        $this->registrationWaitlist->attach($registration);
770
    }
771
772
    public function removeRegistrationWaitlist(Registration $registrationToRemove)
773
    {
774
        $this->registrationWaitlist->detach($registrationToRemove);
775
    }
776
777
    /**
778
     * Returns, if cancellation for registrations of the event is possible
779
     *
780
     * @return bool
781
     */
782
    public function getCancellationPossible(): bool
783
    {
784
        $today = new DateTime('today');
785
786
        return ($this->getEnableCancel() && $this->getCancelDeadline() > $today) ||
787
            ($this->getEnableCancel() && $this->getCancelDeadline() === null && $this->getStartdate() > $today);
788
    }
789
790
    public function getSpeaker(): ?ObjectStorage
791
    {
792
        return $this->speaker;
793
    }
794
795
    public function setSpeaker(?ObjectStorage $speaker)
796
    {
797
        $this->speaker = $speaker;
798
    }
799
800
    public function addSpeaker(Speaker $speaker)
801
    {
802
        $this->speaker->attach($speaker);
803
    }
804
805
    public function removeSpeaker(Speaker $speaker)
806
    {
807
        $this->speaker->detach($speaker);
808
    }
809
810
    public function getRegistrationFields(): ?ObjectStorage
811
    {
812
        return $this->registrationFields;
813
    }
814
815
    public function setRegistrationFields(?ObjectStorage $registrationFields)
816
    {
817
        $this->registrationFields = $registrationFields;
818
    }
819
820
    public function addRegistrationFields(Field $registrationField)
821
    {
822
        $this->registrationFields->attach($registrationField);
823
    }
824
825
    public function removeRegistrationFields(Field $registrationField)
826
    {
827
        $this->registrationFields->detach($registrationField);
828
    }
829
830
    public function getRegistrationFieldsUids(): array
831
    {
832
        $result = [];
833
        foreach ($this->registrationFields as $registrationField) {
834
            $result[] = $registrationField->getUid();
835
        }
836
837
        return $result;
838
    }
839
840
    /**
841
     * Returns an array with registration field uids and titles
842
     * [uid => title]
843
     *
844
     * @return array
845
     */
846
    public function getRegistrationFieldUidsWithTitle(): array
847
    {
848
        $result = [];
849
        foreach ($this->registrationFields as $registrationField) {
850
            $result[$registrationField->getUid()] = $registrationField->getTitle();
851
        }
852
853
        return $result;
854
    }
855
856
    /**
857
     * Special getter to return the amount of registrations that are saved to default language
858
     * Required since TYPO3 9.5 (#82363)
859
     *
860
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
861
     */
862
    public function getRegistrations(): ?ObjectStorage
863
    {
864
        $languageAspect = GeneralUtility::makeInstance(Context::class)->getAspect('language');
865
        if ($languageAspect->getId() > 0) {
866
            return $this->getRegistrationsDefaultLanguage(false);
867
        }
868
869
        return $this->registration;
870
    }
871
872
    /**
873
     * Special getter to return the amount of waitlist registrations that are saved to default language
874
     * Required since TYPO3 9.5 (#82363)
875
     *
876
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
877
     */
878
    public function getRegistrationsWaitlist(): ?ObjectStorage
879
    {
880
        $languageAspect = GeneralUtility::makeInstance(Context::class)->getAspect('language');
881
        if ($languageAspect->getId() > 0) {
882
            return $this->getRegistrationsDefaultLanguage(true);
883
        }
884
885
        return $this->registrationWaitlist;
886
    }
887
888
    /**
889
     * Returns an objectStorage object holding all registrations in the default language.
890
     * Ensures expected behavior of getRegistration() and getRegistrationWaitlist() since TYPO3 issue #82363
891
     *
892
     * @param bool $waitlist
893
     * @return ObjectStorage
894
     */
895
    protected function getRegistrationsDefaultLanguage(bool $waitlist = false): ObjectStorage
896
    {
897
        $result = GeneralUtility::makeInstance(ObjectStorage::class);
898
        $registrationRepository = GeneralUtility::makeInstance(RegistrationRepository::class);
899
        $registrations = $registrationRepository->findByEventAndWaitlist($this, $waitlist);
900
        foreach ($registrations as $registration) {
901
            $result->attach($registration);
902
        }
903
904
        return $result;
905
    }
906
907
    public function getEndsSameDay(): bool
908
    {
909
        if ($this->enddate !== null) {
910
            return $this->startdate->format('d.m.Y') === $this->enddate->format('d.m.Y');
0 ignored issues
show
Bug introduced by
The method format() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

910
            return $this->startdate->/** @scrutinizer ignore-call */ format('d.m.Y') === $this->enddate->format('d.m.Y');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
911
        }
912
913
        return true;
914
    }
915
916
    public function getSpamCheckChallenge(): string
917
    {
918
        return MiscUtility::getSpamCheckChallenge($this->getUid());
0 ignored issues
show
Bug introduced by
It seems like $this->getUid() can also be of type null; however, parameter $eventUid of DERHANSEN\SfEventMgt\Uti...getSpamCheckChallenge() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

918
        return MiscUtility::getSpamCheckChallenge(/** @scrutinizer ignore-type */ $this->getUid());
Loading history...
919
    }
920
921
    /**
922
     * Returns a string to be used as overlay value for the <core:icon> ViewHelper in the Backend Modules
923
     *
924
     * @return string
925
     */
926
    public function getBackendIconOverlay(): string
927
    {
928
        $overlay = '';
929
        if ($this->getHidden()) {
930
            $overlay = 'overlay-hidden';
931
        }
932
        if (!$this->getHidden() && ($this->getStarttime() || $this->getEndtime())) {
933
            $overlay = 'overlay-endtime';
934
        }
935
936
        return $overlay;
937
    }
938
}
939