Passed
Push — 5.x ( 4b363f...613d87 )
by Torben
05:36
created

Event   F

Complexity

Total Complexity 166

Size/Duplication

Total Lines 1688
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 166
eloc 248
c 1
b 0
f 0
dl 0
loc 1688
rs 2

127 Methods

Rating   Name   Duplication   Size   Complexity  
C getRegistrationPossible() 0 18 13
A addRegistrationFields() 0 3 1
A removeAdditionalImage() 0 3 1
A getOrganisator() 0 3 1
A setStarttime() 0 3 1
A setEnableCancel() 0 3 1
A setUniqueEmailCheck() 0 3 1
A getEnableCancel() 0 3 1
A setMaxParticipants() 0 3 1
A getLocation() 0 3 1
A setStartdate() 0 3 1
A setProgram() 0 3 1
A getRelated() 0 3 1
A getNotifyAdmin() 0 3 1
A getTitle() 0 3 1
A setEnableRegistration() 0 3 1
A getImage() 0 3 1
A removeRegistration() 0 3 1
A addImage() 0 3 1
A getRoom() 0 3 1
A getRegistration() 0 3 1
A getRegistrationDeadline() 0 3 1
A getRestrictPaymentMethods() 0 3 1
A setHidden() 0 3 1
A getEnableAutoconfirm() 0 3 1
A setNotifyOrganisator() 0 3 1
A getDescription() 0 3 1
A getFiles() 0 3 1
A getEndtime() 0 3 1
A getAdditionalImage() 0 3 1
A setCategory() 0 3 1
A getCancellationPossible() 0 6 5
A setRelated() 0 3 1
A getRegistrationFields() 0 3 1
A setMaxRegistrationsPerUser() 0 3 1
A setRoom() 0 3 1
A getEnddate() 0 3 1
A removeRegistrationWaitlist() 0 3 1
A getEndsSameDay() 0 7 2
A removeSpeaker() 0 3 1
B getBackendIconOverlay() 0 15 8
A setTstamp() 0 3 1
A removeRelated() 0 3 1
A getRegistrations() 0 8 2
A getProgram() 0 3 1
A setSpeaker() 0 3 1
A getMaxRegistrationsPerUser() 0 3 1
A removeImage() 0 3 1
A addRegistration() 0 3 1
A getTeaser() 0 3 1
A setRegistrationDeadline() 0 3 1
A getRegistrationsDefaultLanguage() 0 11 2
A setCancelDeadline() 0 3 1
A setLocation() 0 3 1
A getRegistrationWaitlist() 0 3 1
A setEnableWaitlist() 0 3 1
A removeFiles() 0 3 1
A setEnableWaitlistMoveup() 0 3 1
A getUniqueEmailCheck() 0 3 1
A getCurrentPrice() 0 9 2
A setRegistration() 0 3 1
A getTstamp() 0 3 1
A setSelectedPaymentMethods() 0 3 1
A setLink() 0 3 1
A setEndtime() 0 3 1
A getStartdate() 0 3 1
A getImages() 0 3 1
A getImagesByType() 0 15 5
A getPriceOptions() 0 3 1
A getCategory() 0 3 1
A getTopEvent() 0 3 1
A getNotifyOrganisator() 0 3 1
A addSpeaker() 0 3 1
A getSpamCheckChallenge() 0 3 1
A getCurrency() 0 3 1
A getCancelDeadline() 0 3 1
A getRegistrationFieldUidsWithTitle() 0 8 2
A setRegistrationFields() 0 3 1
A getStarttime() 0 3 1
A setAdditionalImage() 0 3 1
A setCurrency() 0 3 1
A setImage() 0 3 1
A setDescription() 0 3 1
A getRegistrationsWaitlist() 0 8 2
A setPriceOptions() 0 3 1
A addPriceOptions() 0 3 1
A setTitle() 0 3 1
A getLink() 0 3 1
A removeCategory() 0 3 1
A setEnableAutoconfirm() 0 3 1
A setRegistrationWaitlist() 0 3 1
A getFirstDetailViewImage() 0 9 2
A getSelectedPaymentMethods() 0 3 1
A getPrice() 0 3 1
A removeRegistrationFields() 0 3 1
A getFreePlaces() 0 3 1
A getEnableWaitlist() 0 3 1
A getEnablePayment() 0 3 1
A getEnableWaitlistMoveup() 0 3 1
A __construct() 0 12 1
A setNotifyAdmin() 0 3 1
A getRegistrationStartdate() 0 3 1
A getListViewImages() 0 3 1
A getFirstListViewImage() 0 9 2
A setPrice() 0 3 1
A setEnddate() 0 3 1
A getMaxParticipants() 0 3 1
A setEnablePayment() 0 3 1
A getRegistrationFieldsUids() 0 8 2
A setRestrictPaymentMethods() 0 3 1
A setOrganisator() 0 3 1
A addRegistrationWaitlist() 0 3 1
A getEnableRegistration() 0 3 1
A getActivePriceOptions() 0 14 4
A setTopEvent() 0 3 1
A addCategory() 0 3 1
A setTeaser() 0 3 1
A getCategories() 0 3 1
A getDetailViewImages() 0 3 1
A removePriceOptions() 0 3 1
A setFiles() 0 3 1
A getSpeaker() 0 3 1
A setRegistrationStartdate() 0 3 1
A getHidden() 0 3 1
A addFiles() 0 3 1
A addAdditionalImage() 0 3 1
A addRelated() 0 3 1

How to fix   Complexity   

Complex Class

Complex classes like Event often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Event, and based on these observations, apply Extract Interface, too.

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

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

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

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

1692
        return MiscUtility::getSpamCheckChallenge(/** @scrutinizer ignore-type */ $this->getUid());
Loading history...
1693
    }
1694
1695
    /**
1696
     * Returns a string to be used as overlay value for the <core:icon> ViewHelper in the Backend Modules
1697
     *
1698
     * @return string
1699
     */
1700
    public function getBackendIconOverlay(): string
1701
    {
1702
        $date = new DateTime();
1703
        $overlay = '';
1704
        if ($this->getHidden()) {
1705
            $overlay = 'overlay-hidden';
1706
        } elseif ($this->getEndtime() && $this->getEndtime() < $date) {
1707
            $overlay = 'overlay-endtime';
1708
        } elseif (($this->getStarttime() && $this->getStarttime() > $date) ||
1709
            ($this->getEndtime() && $this->getEndtime() > $date)
1710
        ) {
1711
            $overlay = 'overlay-scheduled';
1712
        }
1713
1714
        return $overlay;
1715
    }
1716
}
1717