Passed
Push — master ( c597bf...58c4da )
by Torben
08:11 queued 05:32
created

Event::getListViewImages()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

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

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

895
            /** @scrutinizer ignore-call */ 
896
            $fileReference = $image->getOriginalResource();
Loading history...
896
            if ($fileReference && $fileReference->hasProperty('show_in_views') &&
897
                in_array($fileReference->getProperty('show_in_views'), [$type, ShowInPreviews::ALL_VIEWS])
898
            ) {
899
                $result->attach($image);
900
            }
901 6
        }
902
903 6
        return $result;
904 6
    }
905
906
    /**
907
     * Sets the image
908
     *
909
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> $image Image
910
     */
911 22
    public function setImage(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $image)
912
    {
913 22
        $this->image = $image;
914
    }
915
916
    /**
917
     * Adds a file
918
     *
919
     * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $file File
920
     */
921
    public function addFiles(\TYPO3\CMS\Extbase\Domain\Model\FileReference $file)
922
    {
923 24
        $this->files->attach($file);
924
    }
925 24
926 24
    /**
927
     * Removes a file
928
     *
929
     * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $fileToRemove File
930
     */
931
    public function removeFiles(\TYPO3\CMS\Extbase\Domain\Model\FileReference $fileToRemove)
932
    {
933 2
        $this->files->detach($fileToRemove);
934
    }
935 2
936
    /**
937
     * Returns the files
938
     *
939
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $files
940
     */
941
    public function getFiles()
942
    {
943 2
        return $this->files;
944
    }
945 2
946
    /**
947
     * Sets the files
948
     *
949
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $files Files
950
     */
951
    public function setFiles(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $files)
952
    {
953 2
        $this->files = $files;
954
    }
955 2
956
    /**
957
     * Returns if the registration for this event is logically possible
958
     *
959
     * @return bool
960
     */
961
    public function getRegistrationPossible()
962
    {
963 2
        $maxParticipantsNotReached = true;
964
        if ($this->getMaxParticipants() > 0 && $this->getRegistrations()->count() >= $this->maxParticipants) {
965 2
            $maxParticipantsNotReached = false;
966
        }
967
        $deadlineNotReached = true;
968
        if ($this->getRegistrationDeadline() != null && $this->getRegistrationDeadline() <= new \DateTime()) {
969
            $deadlineNotReached = false;
970
        }
971
        $registrationStartReached = true;
972
        if ($this->getRegistrationStartdate() != null && $this->getRegistrationStartdate() > new \DateTime()) {
973
            $registrationStartReached = false;
974
        }
975
976
        return ($this->getStartdate() > new \DateTime()) &&
977 22
        ($maxParticipantsNotReached || !$maxParticipantsNotReached && $this->enableWaitlist) &&
978
        $this->getEnableRegistration() && $deadlineNotReached && $registrationStartReached;
979 22
    }
980 22
981 22
    /**
982 22
     * Returns the amount of free places
983 22
     *
984 22
     * @return int
985 2
     */
986 2
    public function getFreePlaces()
987 22
    {
988
        return $this->maxParticipants - $this->getRegistrations()->count();
989
    }
990
991
    /**
992
     * Sets the location
993
     *
994
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Location $location Location
995
     */
996
    public function setLocation($location)
997 2
    {
998
        $this->location = $location;
999 2
    }
1000 2
1001
    /**
1002
     * Returns the location
1003
     *
1004
     * @return \DERHANSEN\SfEventMgt\Domain\Model\Location
1005
     */
1006
    public function getLocation()
1007 2
    {
1008
        return $this->location;
1009 2
    }
1010
1011
    /**
1012
     * Returns the room
1013
     *
1014
     * @return string
1015
     */
1016
    public function getRoom()
1017 4
    {
1018
        return $this->room;
1019 4
    }
1020
1021
    /**
1022
     * Sets the room
1023
     *
1024
     * @param string $room
1025
     */
1026
    public function setRoom($room)
1027
    {
1028
        $this->room = $room;
1029 2
    }
1030
1031 2
    /**
1032 2
     * Sets enableRegistration
1033
     *
1034
     * @param bool $enableRegistration EnableRegistration
1035
     */
1036
    public function setEnableRegistration($enableRegistration)
1037
    {
1038
        $this->enableRegistration = $enableRegistration;
1039
    }
1040
1041
    /**
1042 2
     * Returns if registration is enabled
1043
     *
1044 2
     * @return bool
1045 2
     */
1046
    public function getEnableRegistration()
1047
    {
1048
        return $this->enableRegistration;
1049
    }
1050
1051
    /**
1052
     * Returns enableWaitlist
1053
     *
1054 2
     * @return bool
1055
     */
1056 2
    public function getEnableWaitlist()
1057 2
    {
1058
        return $this->enableWaitlist;
1059
    }
1060
1061
    /**
1062
     * Sets enableWaitlist
1063
     *
1064 2
     * @param bool $enableWaitlist
1065
     */
1066 2
    public function setEnableWaitlist($enableWaitlist)
1067
    {
1068
        $this->enableWaitlist = $enableWaitlist;
1069
    }
1070
1071
    /**
1072
     * @return bool
1073
     */
1074
    public function getEnableWaitlistMoveup(): bool
1075
    {
1076 6
        return $this->enableWaitlistMoveup;
1077
    }
1078 6
1079 6
    /**
1080
     * @param bool $enableWaitlistMoveup
1081
     */
1082
    public function setEnableWaitlistMoveup($enableWaitlistMoveup): void
1083
    {
1084
        $this->enableWaitlistMoveup = $enableWaitlistMoveup;
1085
    }
1086 12
1087
    /**
1088 12
     * Sets the registration startdate
1089
     *
1090
     * @param \DateTime $registrationStartdate RegistrationStartdate
1091
     */
1092
    public function setRegistrationStartdate(\DateTime $registrationStartdate)
1093
    {
1094
        $this->registrationStartdate = $registrationStartdate;
1095
    }
1096
1097
    /**
1098 12
     * Returns the registration startdate
1099
     *
1100 12
     * @return \DateTime
1101 12
     */
1102
    public function getRegistrationStartdate()
1103
    {
1104
        return $this->registrationStartdate;
1105
    }
1106
1107
    /**
1108 54
     * Sets the registration deadline
1109
     *
1110 54
     * @param \DateTime $registrationDeadline RegistrationDeadline
1111
     */
1112
    public function setRegistrationDeadline(\DateTime $registrationDeadline)
1113
    {
1114
        $this->registrationDeadline = $registrationDeadline;
1115
    }
1116
1117
    /**
1118
     * Returns the registration deadline
1119
     *
1120 22
     * @return \DateTime
1121
     */
1122 22
    public function getRegistrationDeadline()
1123 22
    {
1124
        return $this->registrationDeadline;
1125
    }
1126
1127
    /**
1128
     * Sets the link
1129
     *
1130 54
     * @param string $link Link
1131
     */
1132 54
    public function setLink($link)
1133
    {
1134
        $this->link = $link;
1135
    }
1136
1137
    /**
1138
     * Returns the link
1139
     *
1140
     * @return string
1141
     */
1142 22
    public function getLink()
1143
    {
1144 22
        return $this->link;
1145 22
    }
1146
1147
    /**
1148
     * Sets topEvent
1149
     *
1150
     * @param bool $topEvent TopEvent
1151
     */
1152
    public function setTopEvent($topEvent)
1153
    {
1154 8
        $this->topEvent = $topEvent;
1155
    }
1156 8
1157 8
    /**
1158
     * Returns if topEvent is checked
1159
     *
1160
     * @return bool
1161
     */
1162
    public function getTopEvent()
1163
    {
1164 10
        return $this->topEvent;
1165
    }
1166 10
1167
    /**
1168
     * Returns max regisrations per user
1169
     *
1170
     * @return int
1171
     */
1172
    public function getMaxRegistrationsPerUser()
1173
    {
1174
        return $this->maxRegistrationsPerUser;
1175
    }
1176 8
1177
    /**
1178 8
     * Sets max registrations per user
1179 8
     *
1180
     * @param int $maxRegistrationsPerUser MaxRegistrationsPerUser
1181
     */
1182
    public function setMaxRegistrationsPerUser($maxRegistrationsPerUser)
1183
    {
1184
        $this->maxRegistrationsPerUser = $maxRegistrationsPerUser;
1185
    }
1186 8
1187
    /**
1188 8
     * Adds an additionalImage
1189
     *
1190
     * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $additionalImage The Image
1191
     */
1192
    public function addAdditionalImage(\TYPO3\CMS\Extbase\Domain\Model\FileReference $additionalImage)
1193
    {
1194
        $this->additionalImage->attach($additionalImage);
1195
    }
1196 4
1197
    /**
1198 4
     * Removes an additionalImage
1199
     *
1200
     * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $additionalImageToRemove The Image
1201
     */
1202
    public function removeAdditionalImage(\TYPO3\CMS\Extbase\Domain\Model\FileReference $additionalImageToRemove)
1203
    {
1204
        $this->additionalImage->detach($additionalImageToRemove);
1205
    }
1206
1207 2
    /**
1208
     * Returns the additionalImage
1209 2
     *
1210 2
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $additionalImage
1211
     */
1212
    public function getAdditionalImage()
1213
    {
1214
        return $this->additionalImage;
1215
    }
1216
1217 10
    /**
1218
     * Sets the additionalImage
1219 10
     *
1220
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $additionalImage The Image
1221
     */
1222
    public function setAdditionalImage(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $additionalImage)
1223
    {
1224
        $this->additionalImage = $additionalImage;
1225
    }
1226
1227
    /**
1228 6
     * Returns the organisator
1229
     *
1230 6
     * @return Organisator
1231 6
     */
1232
    public function getOrganisator()
1233
    {
1234
        return $this->organisator;
1235
    }
1236
1237
    /**
1238
     * Sets the organisator
1239
     *
1240 6
     * @param Organisator $organisator The organisator
1241
     */
1242 6
    public function setOrganisator($organisator)
1243 6
    {
1244
        $this->organisator = $organisator;
1245
    }
1246
1247
    /**
1248
     * Returns notifyAdmin
1249
     *
1250
     * @return bool
1251
     */
1252 2
    public function getNotifyAdmin()
1253
    {
1254 2
        return $this->notifyAdmin;
1255 2
    }
1256
1257
    /**
1258
     * Sets notifyAdmin
1259
     *
1260
     * @param bool $notifyAdmin NotifyAdmin
1261
     */
1262 6
    public function setNotifyAdmin($notifyAdmin)
1263
    {
1264 6
        $this->notifyAdmin = $notifyAdmin;
1265 6
    }
1266 6
1267 6
    /**
1268 4
     * Returns if notifyAdmin is set
1269 4
     *
1270 4
     * @return bool
1271 6
     */
1272 6
    public function getNotifyOrganisator()
1273 6
    {
1274 6
        return $this->notifyOrganisator;
1275
    }
1276
1277
    /**
1278
     * Sets notifyOrganisator
1279
     *
1280
     * @param bool $notifyOrganisator NotifyOrganisator
1281
     */
1282 4
    public function setNotifyOrganisator($notifyOrganisator)
1283
    {
1284 4
        $this->notifyOrganisator = $notifyOrganisator;
1285 4
    }
1286
1287 2
    /**
1288
     * Sets enableCancel
1289
     *
1290 2
     * @param bool $enableCancel EnableCancel
1291
     */
1292
    public function setEnableCancel($enableCancel)
1293
    {
1294
        $this->enableCancel = $enableCancel;
1295
    }
1296
1297
    /**
1298
     * Returns if registration can be canceled
1299 2
     *
1300
     * @return bool
1301 2
     */
1302
    public function getEnableCancel()
1303
    {
1304
        return $this->enableCancel;
1305
    }
1306
1307
    /**
1308
     * Sets the cancel deadline
1309
     *
1310
     * @param \DateTime $cancelDeadline CancelDeadline
1311 6
     */
1312
    public function setCancelDeadline(\DateTime $cancelDeadline)
1313 6
    {
1314 6
        $this->cancelDeadline = $cancelDeadline;
1315
    }
1316
1317
    /**
1318
     * Returns the cancel deadline
1319
     *
1320
     * @return \DateTime
1321
     */
1322
    public function getCancelDeadline()
1323 2
    {
1324
        return $this->cancelDeadline;
1325 2
    }
1326 2
1327
    /**
1328
     * Returns if autoconfirmation is enabled
1329
     *
1330
     * @return bool
1331
     */
1332
    public function getEnableAutoconfirm()
1333
    {
1334
        return $this->enableAutoconfirm;
1335 2
    }
1336
1337 2
    /**
1338 2
     * Sets enable autoconfirm
1339
     *
1340
     * @param bool $enableAutoconfirm
1341
     */
1342
    public function setEnableAutoconfirm($enableAutoconfirm)
1343
    {
1344
        $this->enableAutoconfirm = $enableAutoconfirm;
1345 6
    }
1346
1347 6
    /**
1348
     * Returns uniqueEmailCheck
1349
     *
1350
     * @return bool
1351
     */
1352
    public function getUniqueEmailCheck()
1353
    {
1354
        return $this->uniqueEmailCheck;
1355
    }
1356
1357
    /**
1358
     * Sets UniqueEmailCheck
1359
     *
1360
     * @param bool $uniqueEmailCheck
1361
     */
1362
    public function setUniqueEmailCheck($uniqueEmailCheck)
1363
    {
1364
        $this->uniqueEmailCheck = $uniqueEmailCheck;
1365
    }
1366
1367
    /**
1368
     * Returns price options
1369
     *
1370
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\DERHANSEN\SfEventMgt\Domain\Model\PriceOption>
1371
     */
1372
    public function getPriceOptions()
1373
    {
1374
        return $this->priceOptions;
1375
    }
1376
1377
    /**
1378
     * Sets price options
1379
     *
1380
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $priceOptions
1381
     */
1382
    public function setPriceOptions($priceOptions)
1383
    {
1384
        $this->priceOptions = $priceOptions;
1385
    }
1386
1387
    /**
1388
     * Adds a price option
1389
     *
1390
     * @param \DERHANSEN\SfEventMgt\Domain\Model\PriceOption $priceOption Price option
1391
     */
1392
    public function addPriceOptions(\DERHANSEN\SfEventMgt\Domain\Model\PriceOption $priceOption)
1393
    {
1394
        $this->priceOptions->attach($priceOption);
1395
    }
1396
1397
    /**
1398
     * Removes a Registration
1399
     *
1400
     * @param \DERHANSEN\SfEventMgt\Domain\Model\PriceOption $priceOption Price option
1401
     */
1402
    public function removePriceOptions(\DERHANSEN\SfEventMgt\Domain\Model\PriceOption $priceOption)
1403
    {
1404
        $this->priceOptions->detach($priceOption);
1405
    }
1406
1407
    /**
1408
     * Returns all active price options sorted by date ASC
1409
     *
1410
     * @return array
1411
     */
1412
    public function getActivePriceOptions()
1413
    {
1414
        $activePriceOptions = [];
1415
        if ($this->getPriceOptions()) {
1416
            $compareDate = new \DateTime('today midnight');
1417
            foreach ($this->getPriceOptions() as $priceOption) {
1418
                if ($priceOption->getValidUntil() >= $compareDate) {
0 ignored issues
show
Bug introduced by
The method getValidUntil() does not exist on TYPO3\CMS\Extbase\Domain...t\DomainObjectInterface. It seems like you code against a sub-type of TYPO3\CMS\Extbase\Domain...t\DomainObjectInterface such as DERHANSEN\SfEventMgt\Domain\Model\PriceOption. ( Ignorable by Annotation )

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

1418
                if ($priceOption->/** @scrutinizer ignore-call */ getValidUntil() >= $compareDate) {
Loading history...
1419
                    $activePriceOptions[$priceOption->getValidUntil()->getTimestamp()] = $priceOption;
1420
                }
1421
            }
1422
        }
1423
        ksort($activePriceOptions);
1424
1425
        return $activePriceOptions;
1426
    }
1427
1428
    /**
1429
     * Returns the current price of the event respecting possible price options
1430
     *
1431
     * @return float
1432
     */
1433
    public function getCurrentPrice()
1434
    {
1435
        $activePriceOptions = $this->getActivePriceOptions();
1436
        if (count($activePriceOptions) >= 1) {
1437
            // Sort active price options and return first element
1438
            return reset($activePriceOptions)->getPrice();
1439
        }
1440
        // Just return the price field
1441
        return $this->price;
1442
    }
1443
1444
    /**
1445
     * Returns registrationWaitlist
1446
     *
1447
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
1448
     */
1449
    public function getRegistrationWaitlist()
1450
    {
1451
        return $this->registrationWaitlist;
1452
    }
1453
1454
    /**
1455
     * Sets registrationWaitlist
1456
     *
1457
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $registration Registration
1458
     */
1459
    public function setRegistrationWaitlist(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $registration)
1460
    {
1461
        $this->registrationWaitlist = $registration;
1462
    }
1463
1464
    /**
1465
     * Adds a Registration to the waitlist
1466
     *
1467
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration Registration
1468
     */
1469
    public function addRegistrationWaitlist(\DERHANSEN\SfEventMgt\Domain\Model\Registration $registration)
1470
    {
1471
        $this->registrationWaitlist->attach($registration);
1472
    }
1473
1474
    /**
1475
     * Removes a Registration from the waitlist
1476
     *
1477
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registrationToRemove Registration
1478
     */
1479
    public function removeRegistrationWaitlist(\DERHANSEN\SfEventMgt\Domain\Model\Registration $registrationToRemove)
1480
    {
1481
        $this->registrationWaitlist->detach($registrationToRemove);
1482
    }
1483
1484
    /**
1485
     * Returns, if cancellation for registrations of the event is possible
1486
     *
1487
     * @return bool
1488
     */
1489
    public function getCancellationPossible()
1490
    {
1491
        $today = new \DateTime('today');
1492
1493
        return ($this->getEnableCancel() && $this->getCancelDeadline() > $today) ||
1494
            ($this->getEnableCancel() && $this->getCancelDeadline() === null && $this->getStartdate() > $today);
1495
    }
1496
1497
    /**
1498
     * Returns speaker
1499
     *
1500
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
1501
     */
1502
    public function getSpeaker()
1503
    {
1504
        return $this->speaker;
1505
    }
1506
1507
    /**
1508
     * Sets speaker
1509
     *
1510
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $speaker
1511
     */
1512
    public function setSpeaker($speaker)
1513
    {
1514
        $this->speaker = $speaker;
1515
    }
1516
1517
    /**
1518
     * Adds a speaker
1519
     *
1520
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Speaker $speaker
1521
     */
1522
    public function addSpeaker(\DERHANSEN\SfEventMgt\Domain\Model\Speaker $speaker)
1523
    {
1524
        $this->speaker->attach($speaker);
1525
    }
1526
1527
    /**
1528
     * Removes a speaker
1529
     *
1530
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Speaker $speaker
1531
     */
1532
    public function removeSpeaker(\DERHANSEN\SfEventMgt\Domain\Model\Speaker $speaker)
1533
    {
1534
        $this->speaker->detach($speaker);
1535
    }
1536
1537
    /**
1538
     * Returns registrationFields
1539
     *
1540
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
1541
     */
1542
    public function getRegistrationFields()
1543
    {
1544
        return $this->registrationFields;
1545
    }
1546
1547
    /**
1548
     * Sets registrationWaitlist
1549
     *
1550
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $registrationFields
1551
     */
1552
    public function setRegistrationFields(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $registrationFields)
1553
    {
1554
        $this->registrationFields = $registrationFields;
1555
    }
1556
1557
    /**
1558
     * Adds a registrationField
1559
     *
1560
     * @param Field $registrationField
1561
     */
1562
    public function addRegistrationFields(Field $registrationField)
1563
    {
1564
        $this->registrationFields->attach($registrationField);
1565
    }
1566
1567
    /**
1568
     * Removed a registrationField
1569
     *
1570
     * @param Field $registrationField
1571
     */
1572
    public function removeRegistrationFields(Field $registrationField)
1573
    {
1574
        $this->registrationFields->detach($registrationField);
1575
    }
1576
1577
    /**
1578
     * Returns an array with registration field uids
1579
     *
1580
     * @return array
1581
     */
1582
    public function getRegistrationFieldsUids()
1583
    {
1584
        $result = [];
1585
        foreach ($this->registrationFields as $registrationField) {
1586
            $result[] = $registrationField->getUid();
1587
        }
1588
1589
        return $result;
1590
    }
1591
1592
    /**
1593
     * Returns an array with registration field uids and titles
1594
     * [uid => title]
1595
     *
1596
     * @return array
1597
     */
1598
    public function getRegistrationFieldUidsWithTitle()
1599
    {
1600
        $result = [];
1601
        foreach ($this->registrationFields as $registrationField) {
1602
            $result[$registrationField->getUid()] = $registrationField->getTitle();
0 ignored issues
show
Bug introduced by
The method getTitle() does not exist on TYPO3\CMS\Extbase\Domain...t\DomainObjectInterface. It seems like you code against a sub-type of TYPO3\CMS\Extbase\Domain...t\DomainObjectInterface such as TYPO3\CMS\Extbase\Domain\Model\FrontendUser or TYPO3\CMS\Extensionmanager\Domain\Model\Extension or TYPO3\CMS\Extbase\Domain\Model\BackendUserGroup or DERHANSEN\SfEventMgt\Domain\Model\Event or TYPO3\CMS\Extbase\Domain\Model\FileMount or DERHANSEN\SfEventMgt\Dom...odel\Registration\Field or TYPO3\CMS\Extensionmanager\Domain\Model\Repository or DERHANSEN\SfEventMgt\Domain\Model\Location or TYPO3\CMS\Extbase\Domain\Model\FrontendUserGroup or TYPO3\CMS\Extbase\Domain\Model\Category or DERHANSEN\SfEventMgt\Domain\Model\Registration. ( Ignorable by Annotation )

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

1602
            /** @scrutinizer ignore-call */ 
1603
            $result[$registrationField->getUid()] = $registrationField->getTitle();
Loading history...
1603
        }
1604
1605
        return $result;
1606
    }
1607
1608
    /**
1609
     * Special getter to return the amount of registrations that are saved to default language
1610
     * Required since TYPO3 9.5 (#82363)
1611
     *
1612
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
1613
     */
1614
    public function getRegistrations()
1615
    {
1616
        $languageAspect = GeneralUtility::makeInstance(Context::class)->getAspect('language');
1617
        if ($languageAspect->getId() > 0) {
1618
            return $this->getRegistrationsDefaultLanguage(false);
1619
        }
1620
1621
        return $this->registration;
1622
    }
1623
1624
    /**
1625
     * Special getter to return the amount of waitlist registrations that are saved to default language
1626
     * Required since TYPO3 9.5 (#82363)
1627
     *
1628
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
1629
     */
1630
    public function getRegistrationsWaitlist()
1631
    {
1632
        $languageAspect = GeneralUtility::makeInstance(Context::class)->getAspect('language');
1633
        if ($languageAspect->getId() > 0) {
1634
            return $this->getRegistrationsDefaultLanguage(true);
1635
        }
1636
1637
        return $this->registrationWaitlist;
1638
    }
1639
1640
    /**
1641
     * Returns an objectStorage object holding all registrations in the default language.
1642
     * Ensures expected behavior of getRegistration() and getRegistrationWaitlist() since TYPO3 issue #82363
1643
     *
1644
     * @param bool $waitlist
1645
     * @return ObjectStorage
1646
     */
1647
    protected function getRegistrationsDefaultLanguage(bool $waitlist = false)
1648
    {
1649
        $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
1650
        $result = $objectManager->get(ObjectStorage::class);
1651
        $registrationRepository = $objectManager->get(RegistrationRepository::class);
1652
        $registrations = $registrationRepository->findByEventAndWaitlist($this, $waitlist);
1653
        foreach ($registrations as $registration) {
1654
            $result->attach($registration);
1655
        }
1656
1657
        return $result;
1658
    }
1659
1660
    /**
1661
     * Returns if the event ends on the same day
1662
     *
1663
     * @return bool
1664
     */
1665
    public function getEndsSameDay(): bool
1666
    {
1667
        if ($this->enddate !== null) {
1668
            return $this->startdate->format('d.m.Y') === $this->enddate->format('d.m.Y');
1669
        }
1670
1671
        return true;
1672
    }
1673
1674
    /**
1675
     * Returns the challenge for the challenge/response spam check
1676
     *
1677
     * @return string
1678
     */
1679
    public function getSpamCheckChallenge(): string
1680
    {
1681
        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

1681
        return MiscUtility::getSpamCheckChallenge(/** @scrutinizer ignore-type */ $this->getUid());
Loading history...
1682
    }
1683
1684
    /**
1685
     * Returns a string to be used as overlay value for the <core:icon> ViewHelper in the Backend Modules
1686
     *
1687
     * @return string
1688
     */
1689
    public function getBackendIconOverlay(): string
1690
    {
1691
        $overlay = '';
1692
        if ($this->getHidden()) {
1693
            $overlay = 'overlay-hidden';
1694
        }
1695
        if (!$this->getHidden() && ($this->getStarttime() || $this->getEndtime())) {
1696
            $overlay = 'overlay-endtime';
1697
        }
1698
1699
        return $overlay;
1700
    }
1701
}
1702