Completed
Push — development ( f51276...b71935 )
by Torben
03:32
created

Event::getRoom()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
namespace DERHANSEN\SfEventMgt\Domain\Model;
3
4
/*
5
 * This file is part of the Extension "sf_event_mgt" for TYPO3 CMS.
6
 *
7
 * For the full copyright and license information, please read the
8
 * LICENSE.txt file that was distributed with this source code.
9
 */
10
11
use DERHANSEN\SfEventMgt\Domain\Model\Registration\Field;
12
use DERHANSEN\SfEventMgt\Domain\Repository\RegistrationRepository;
13
use TYPO3\CMS\Core\Utility\GeneralUtility;
14
use TYPO3\CMS\Extbase\Object\ObjectManager;
15
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
16
17
/**
18
 * Event
19
 *
20
 * @author Torben Hansen <[email protected]>
21
 */
22
class Event extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
23
{
24
    /**
25
     * @var \DateTime
26
     */
27
    protected $tstamp;
28
29
    /**
30
     * Title
31
     *
32
     * @var string
33
     * @validate NotEmpty
34
     */
35
    protected $title = '';
36
37
    /**
38
     * Teaser
39
     *
40
     * @var string
41
     */
42
    protected $teaser = '';
43
44
    /**
45
     * Description
46
     *
47
     * @var string
48
     */
49
    protected $description = '';
50
51
    /**
52
     * Program/Schedule
53
     *
54
     * @var string
55
     */
56
    protected $program = '';
57
58
    /**
59
     * Startdate and time
60
     *
61
     * @var \DateTime
62
     */
63
    protected $startdate = null;
64
65
    /**
66
     * Enddate and time
67
     *
68
     * @var \DateTime
69
     */
70
    protected $enddate = null;
71
72
    /**
73
     * Max participants
74
     *
75
     * @var int
76
     */
77
    protected $maxParticipants = 0;
78
79
    /**
80
     * Max registrations per user
81
     *
82
     * @var int
83
     */
84
    protected $maxRegistrationsPerUser = 1;
85
86
    /**
87
     * Price
88
     *
89
     * @var float
90
     */
91
    protected $price = 0.0;
92
93
    /**
94
     * Currency
95
     *
96
     * @var string
97
     */
98
    protected $currency = '';
99
100
    /**
101
     * Enable payment
102
     *
103
     * @var bool
104
     */
105
    protected $enablePayment = false;
106
107
    /**
108
     * Restrict payment methods
109
     *
110
     * @var bool
111
     */
112
    protected $restrictPaymentMethods = false;
113
114
    /**
115
     * Selected payment methods
116
     *
117
     * @var string
118
     */
119
    protected $selectedPaymentMethods = '';
120
121
    /**
122
     * Category
123
     *
124
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\DERHANSEN\SfEventMgt\Domain\Model\Category>
125
     * @lazy
126
     */
127
    protected $category = null;
128
129
    /**
130
     * Related
131
     *
132
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\DERHANSEN\SfEventMgt\Domain\Model\Event>
133
     * @lazy
134
     */
135
    protected $related;
136
137
    /**
138
     * Registration
139
     *
140
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\DERHANSEN\SfEventMgt\Domain\Model\Registration>
141
     * @cascade remove
142
     * @lazy
143
     */
144
    protected $registration = null;
145
146
    /**
147
     * Registration waitlist
148
     *
149
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\DERHANSEN\SfEventMgt\Domain\Model\Registration>
150
     * @lazy
151
     */
152
    protected $registrationWaitlist;
153
154
    /**
155
     * Registration fields
156
     *
157
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\DERHANSEN\SfEventMgt\Domain\Model\Registration\Field>
158
     * @lazy
159
     */
160
    protected $registrationFields;
161
162
    /**
163
     * Registration deadline date
164
     *
165
     * @var \DateTime
166
     */
167
    protected $registrationDeadline = null;
168
169
    /**
170
     * The image
171
     *
172
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
173
     * @lazy
174
     */
175
    protected $image = null;
176
177
    /**
178
     * Additional files
179
     *
180
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
181
     * @lazy
182
     */
183
    protected $files = null;
184
185
    /**
186
     * The Location
187
     *
188
     * @var \DERHANSEN\SfEventMgt\Domain\Model\Location
189
     */
190
    protected $location = null;
191
192
    /**
193
     * Room
194
     *
195
     * @var string
196
     */
197
    protected $room;
198
199
    /**
200
     * Enable registration
201
     *
202
     * @var bool
203
     */
204
    protected $enableRegistration = false;
205
206
    /**
207
     * Enable waitlist
208
     *
209
     * @var bool
210
     */
211
    protected $enableWaitlist = false;
212
213
    /**
214
     * Link
215
     *
216
     * @var string
217
     */
218
    protected $link;
219
220
    /**
221
     * Top event
222
     *
223
     * @var bool
224
     */
225
    protected $topEvent = false;
226
227
    /**
228
     * The additionalImage
229
     *
230
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference>
231
     * @lazy
232
     */
233
    protected $additionalImage = null;
234
235
    /**
236
     * The organisator
237
     *
238
     * @var \DERHANSEN\SfEventMgt\Domain\Model\Organisator
239
     */
240
    protected $organisator = null;
241
242
    /**
243
     * Notify admin
244
     *
245
     * @var bool
246
     */
247
    protected $notifyAdmin = true;
248
249
    /**
250
     * Notify organisator
251
     *
252
     * @var bool
253
     */
254
    protected $notifyOrganisator = false;
255
256
    /**
257
     * Enable cancel of registration
258
     *
259
     * @var bool
260
     */
261
    protected $enableCancel = false;
262
263
    /**
264
     * Deadline for cancel
265
     *
266
     * @var \DateTime
267
     */
268
    protected $cancelDeadline = null;
269
270
    /**
271
     * Enable auto confirmation
272
     *
273
     * @var bool
274
     */
275
    protected $enableAutoconfirm = false;
276
277 181
    /**
278
     * Unique e-mail check
279 181
     *
280 181
     * @var bool
281 181
     */
282 181
    protected $uniqueEmailCheck = false;
283 181
284 181
    /**
285 181
     * Price options
286 181
     *
287 181
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\DERHANSEN\SfEventMgt\Domain\Model\PriceOption>
288
     * @cascade remove
289
     * @lazy
290
     */
291
    protected $priceOptions = null;
292
293
    /**
294 9
     * Speaker
295
     *
296 9
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\DERHANSEN\SfEventMgt\Domain\Model\Speaker>
297
     * @lazy
298
     */
299
    protected $speaker = null;
300
301
    /**
302
     * Constructor
303
     */
304
    public function __construct()
305
    {
306 1
        $this->category = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
307
        $this->related = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
308 1
        $this->registration = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
309 1
        $this->registrationWaitlist = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
310
        $this->registrationFields = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
311
        $this->image = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
312
        $this->files = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
313
        $this->additionalImage = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
314
        $this->priceOptions = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
315
        $this->speaker = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
316 1
    }
317
318 1
    /**
319
     * Get timestamp
320
     *
321
     * @return \DateTime
322
     */
323
    public function getTstamp()
324
    {
325
        return $this->tstamp;
326
    }
327
328 1
    /**
329
     * Set time stamp
330 1
     *
331 1
     * @param \DateTime $tstamp time stamp
332
     */
333
    public function setTstamp($tstamp)
334
    {
335
        $this->tstamp = $tstamp;
336
    }
337
338 1
    /**
339
     * Returns the title
340 1
     *
341
     * @return string $title
342
     */
343
    public function getTitle()
344
    {
345
        return $this->title;
346
    }
347
348
    /**
349
     * Sets the title
350 1
     *
351
     * @param string $title Title
352 1
     *
353 1
     * @return void
354
     */
355
    public function setTitle($title)
356
    {
357
        $this->title = $title;
358
    }
359
360 1
    /**
361
     * Returns the teaser
362 1
     *
363
     * @return string
364
     */
365
    public function getTeaser()
366
    {
367
        return $this->teaser;
368
    }
369
370
    /**
371
     * Sets the teaser
372 1
     *
373
     * @param string $teaser Teaser
374 1
     *
375 1
     * @return void
376
     */
377
    public function setTeaser($teaser)
378
    {
379
        $this->teaser = $teaser;
380
    }
381
382 11
    /**
383
     * Returns the description
384 11
     *
385
     * @return string $description
386
     */
387
    public function getDescription()
388
    {
389
        return $this->description;
390
    }
391
392
    /**
393
     * Sets the description
394 11
     *
395
     * @param string $description Description
396 11
     *
397 11
     * @return void
398
     */
399
    public function setDescription($description)
400
    {
401
        $this->description = $description;
402
    }
403
404 1
    /**
405
     * Returns the program
406 1
     *
407
     * @return string $program
408
     */
409
    public function getProgram()
410
    {
411
        return $this->program;
412
    }
413
414
    /**
415
     * Sets the program
416 1
     *
417
     * @param string $program The program
418 1
     *
419 1
     * @return void
420
     */
421
    public function setProgram($program)
422
    {
423
        $this->program = $program;
424
    }
425
426 14
    /**
427
     * Returns the startdate
428 14
     *
429
     * @return \DateTime $startdate
430
     */
431
    public function getStartdate()
432
    {
433
        return $this->startdate;
434
    }
435
436
    /**
437
     * Sets the startdate
438 13
     *
439
     * @param \DateTime $startdate Startdate
440 13
     *
441 13
     * @return void
442
     */
443
    public function setStartdate(\DateTime $startdate)
444
    {
445
        $this->startdate = $startdate;
446
    }
447
448 1
    /**
449
     * Returns the enddate
450 1
     *
451
     * @return \DateTime $enddate
452
     */
453
    public function getEnddate()
454
    {
455
        return $this->enddate;
456
    }
457
458
    /**
459
     * Sets the enddate
460 3
     *
461
     * @param \DateTime $enddate Enddate
462 3
     *
463 3
     * @return void
464
     */
465
    public function setEnddate(\DateTime $enddate)
466
    {
467
        $this->enddate = $enddate;
468
    }
469
470 1
    /**
471
     * Returns the participants
472 1
     *
473
     * @return int $participants
474
     */
475
    public function getMaxParticipants()
476
    {
477
        return $this->maxParticipants;
478
    }
479
480
    /**
481
     * Sets the participants
482 1
     *
483
     * @param int $participants Participants
484 1
     *
485 1
     * @return void
486
     */
487
    public function setMaxParticipants($participants)
488
    {
489
        $this->maxParticipants = $participants;
490
    }
491
492 4
    /**
493
     * Returns the price
494 4
     *
495
     * @return float $price
496
     */
497
    public function getPrice()
498
    {
499
        return $this->price;
500
    }
501
502
    /**
503 3
     * Sets the price
504
     *
505 3
     * @param float $price Price
506 3
     *
507
     * @return void
508
     */
509
    public function setPrice($price)
510
    {
511
        $this->price = $price;
512
    }
513 3
514
    /**
515 3
     * Returns the currency
516
     *
517
     * @return string $currency
518
     */
519
    public function getCurrency()
520
    {
521
        return $this->currency;
522
    }
523
524 1
    /**
525
     * Sets the currency
526 1
     *
527 1
     * @param string $currency Currency
528
     *
529
     * @return void
530
     */
531
    public function setCurrency($currency)
532
    {
533
        $this->currency = $currency;
534 2
    }
535
536 2
    /**
537
     * Returns if payment is enabled
538
     *
539
     * @return bool
540
     */
541
    public function getEnablePayment()
542
    {
543
        return $this->enablePayment;
544
    }
545 1
546
    /**
547 1
     * Sets enablePayment
548 1
     *
549
     * @param bool $enablePayment
550
     * @return void
551
     */
552
    public function setEnablePayment($enablePayment)
553
    {
554
        $this->enablePayment = $enablePayment;
555
    }
556
557 1
    /**
558
     * Returns if payment methods should be restricted
559 1
     *
560 1
     * @return bool
561
     */
562
    public function getRestrictPaymentMethods()
563
    {
564
        return $this->restrictPaymentMethods;
565
    }
566
567
    /**
568
     * Sets if payment methods should be restricted
569 1
     *
570
     * @param bool $restrictPaymentMethods
571 1
     * @return void
572 1
     */
573
    public function setRestrictPaymentMethods($restrictPaymentMethods)
574
    {
575
        $this->restrictPaymentMethods = $restrictPaymentMethods;
576
    }
577
578
    /**
579 1
     * Returns selected payment methods
580
     *
581 1
     * @return string
582
     */
583
    public function getSelectedPaymentMethods()
584
    {
585
        return $this->selectedPaymentMethods;
586
    }
587
588
    /**
589
     * Sets selected payment methods
590
     *
591 3
     * @param string $selectedPaymentMethods
592
     * @return void
593 3
     */
594 3
    public function setSelectedPaymentMethods($selectedPaymentMethods)
595
    {
596
        $this->selectedPaymentMethods = $selectedPaymentMethods;
597
    }
598
599
    /**
600
     * Adds a Category
601 2
     *
602
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Category $category Category
603 2
     *
604
     * @return void
605
     */
606
    public function addCategory(\DERHANSEN\SfEventMgt\Domain\Model\Category $category)
607
    {
608
        $this->category->attach($category);
609
    }
610
611
    /**
612 3
     * Removes a Category
613
     *
614 3
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Category $categoryToRemove The Category to be removed
615 3
     *
616
     * @return void
617
     */
618
    public function removeCategory(\DERHANSEN\SfEventMgt\Domain\Model\Category $categoryToRemove)
619
    {
620
        $this->category->detach($categoryToRemove);
621
    }
622
623 1
    /**
624
     * Returns the category
625 1
     *
626 1
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
627
     */
628
    public function getCategory()
629
    {
630
        return $this->category;
631
    }
632
633
    /**
634 1
     * Sets the category
635
     *
636 1
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $category Category
637 1
     *
638
     * @return void
639
     */
640
    public function setCategory(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $category)
641
    {
642
        $this->category = $category;
643
    }
644
645
    /**
646 2
     * Returns related events
647
     *
648 2
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
649 2
     */
650
    public function getRelated()
651
    {
652
        return $this->related;
653
    }
654
655
    /**
656
     * Sets related events
657
     *
658 1
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $related
659
     * @return void
660 1
     */
661 1
    public function setRelated($related)
662
    {
663
        $this->related = $related;
664
    }
665
666
    /**
667
     * Adds a related event
668 12
     *
669
     * @param Event $event
670 12
     * @return void
671
     */
672
    public function addRelated(\DERHANSEN\SfEventMgt\Domain\Model\Event $event)
673
    {
674
        $this->related->attach($event);
675
    }
676
677
    /**
678
     * Removes a related event
679
     *
680 9
     * @param Event $event
681
     * @return void
682 9
     */
683 9
    public function removeRelated(\DERHANSEN\SfEventMgt\Domain\Model\Event $event)
684
    {
685
        $this->related->detach($event);
686
    }
687
688
    /**
689
     * Adds a Registration
690
     *
691
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration Registration
692 1
     *
693
     * @return void
694 1
     */
695 1
    public function addRegistration(\DERHANSEN\SfEventMgt\Domain\Model\Registration $registration)
696
    {
697
        $this->registration->attach($registration);
698
    }
699
700
    /**
701
     * Removes a Registration
702
     *
703
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registrationToRemove Registration
704 1
     *
705
     * @return void
706 1
     */
707 1
    public function removeRegistration(\DERHANSEN\SfEventMgt\Domain\Model\Registration $registrationToRemove)
708
    {
709
        $this->registration->detach($registrationToRemove);
710
    }
711
712
    /**
713
     * Returns the Registration
714 1
     *
715
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $registration
716 1
     */
717
    public function getRegistration()
718
    {
719
        return $this->registration;
720
    }
721
722
    /**
723
     * Sets the Registration
724
     *
725
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $registration Registration
726 3
     *
727
     * @return void
728 3
     */
729 3
    public function setRegistration(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $registration)
730
    {
731
        $this->registration = $registration;
732
    }
733
734
    /**
735
     * Adds an image
736
     *
737
     * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $image Image
738 2
     *
739
     * @return void
740 2
     */
741 2
    public function addImage(\TYPO3\CMS\Extbase\Domain\Model\FileReference $image)
742
    {
743
        $this->image->attach($image);
744
    }
745
746
    /**
747
     * Removes an image
748
     *
749
     * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $imageToRemove Image
750 1
     *
751
     * @return void
752 1
     */
753 1
    public function removeImage(\TYPO3\CMS\Extbase\Domain\Model\FileReference $imageToRemove)
754
    {
755
        $this->image->detach($imageToRemove);
756
    }
757
758
    /**
759
     * Returns the image
760 1
     *
761
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $image
762 1
     */
763
    public function getImage()
764
    {
765
        return $this->image;
766
    }
767
768
    /**
769
     * Sets the image
770
     *
771
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $image Image
772 3
     *
773
     * @return void
774 3
     */
775 3
    public function setImage(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $image)
776
    {
777
        $this->image = $image;
778
    }
779
780
    /**
781
     * Adds a file
782 2
     *
783
     * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $file File
784 2
     *
785
     * @return void
786
     */
787
    public function addFiles(\TYPO3\CMS\Extbase\Domain\Model\FileReference $file)
788
    {
789
        $this->files->attach($file);
790
    }
791
792
    /**
793
     * Removes a file
794 1
     *
795
     * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $fileToRemove File
796 1
     *
797 1
     * @return void
798
     */
799
    public function removeFiles(\TYPO3\CMS\Extbase\Domain\Model\FileReference $fileToRemove)
800
    {
801
        $this->files->detach($fileToRemove);
802
    }
803
804 10
    /**
805
     * Returns the files
806 10
     *
807 10
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $files
808 3
     */
809 3
    public function getFiles()
810 10
    {
811 10
        return $this->files;
812 1
    }
813 1
814 10
    /**
815 10
     * Sets the files
816 10
     *
817
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $files Files
818
     *
819
     * @return void
820
     */
821
    public function setFiles(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $files)
822
    {
823
        $this->files = $files;
824 5
    }
825
826 5
    /**
827
     * Returns if the registration for this event is logically possible
828
     *
829
     * @return bool
830
     */
831
    public function getRegistrationPossible()
832
    {
833
        $maxParticipantsNotReached = true;
834
        if ($this->getMaxParticipants() > 0 && $this->getRegistrations()->count() >= $this->maxParticipants) {
835
            $maxParticipantsNotReached = false;
836 1
        }
837
        $deadlineNotReached = true;
838 1
        if ($this->getRegistrationDeadline() != null && $this->getRegistrationDeadline() <= new \DateTime()) {
839 1
            $deadlineNotReached = false;
840
        }
841
842
        return ($this->getStartdate() > new \DateTime()) &&
843
        ($maxParticipantsNotReached || !$maxParticipantsNotReached && $this->enableWaitlist) &&
844
        $this->getEnableRegistration() && $deadlineNotReached;
845
    }
846 1
847
    /**
848 1
     * Returns the amount of free places
849
     *
850
     * @return int
851
     */
852
    public function getFreePlaces()
853
    {
854
        return $this->maxParticipants - $this->getRegistrations()->count();
855
    }
856
857
    /**
858 10
     * Sets the location
859
     *
860 10
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Location $location Location
861 10
     *
862
     * @return void
863
     */
864
    public function setLocation($location)
865
    {
866
        $this->location = $location;
867
    }
868 8
869
    /**
870 8
     * Returns the location
871
     *
872
     * @return \DERHANSEN\SfEventMgt\Domain\Model\Location
873
     */
874
    public function getLocation()
875
    {
876
        return $this->location;
877
    }
878 4
879
    /**
880 4
     * Returns the room
881
     *
882
     * @return string
883
     */
884
    public function getRoom()
885
    {
886
        return $this->room;
887
    }
888
889 5
    /**
890
     * Sets the room
891 5
     *
892 5
     * @param string $room
893
     */
894
    public function setRoom($room)
895
    {
896
        $this->room = $room;
897
    }
898
899
    /**
900
     * Sets enableRegistration
901 3
     *
902
     * @param bool $enableRegistration EnableRegistration
903 3
     *
904 3
     * @return void
905
     */
906
    public function setEnableRegistration($enableRegistration)
907
    {
908
        $this->enableRegistration = $enableRegistration;
909
    }
910
911 11
    /**
912
     * Returns if registration is enabled
913 11
     *
914
     * @return bool
915
     */
916
    public function getEnableRegistration()
917
    {
918
        return $this->enableRegistration;
919
    }
920
921
    /**
922
     * Returns enableWaitlist
923 12
     *
924
     * @return bool
925 12
     */
926 12
    public function getEnableWaitlist()
927
    {
928
        return $this->enableWaitlist;
929
    }
930
931
    /**
932
     * Sets enableWaitlist
933 1
     *
934
     * @param bool $enableWaitlist
935 1
     * @return void
936
     */
937
    public function setEnableWaitlist($enableWaitlist)
938
    {
939
        $this->enableWaitlist = $enableWaitlist;
940
    }
941
942
    /**
943 1
     * Sets the registration deadline
944
     *
945 1
     * @param \DateTime $registrationDeadline RegistrationDeadline
946
     *
947
     * @return void
948
     */
949
    public function setRegistrationDeadline(\DateTime $registrationDeadline)
950
    {
951
        $this->registrationDeadline = $registrationDeadline;
952
    }
953 1
954
    /**
955 1
     * Returns the registration deadline
956
     *
957
     * @return \DateTime
958
     */
959
    public function getRegistrationDeadline()
960
    {
961
        return $this->registrationDeadline;
962
    }
963 1
964
    /**
965 1
     * Sets the link
966
     *
967
     * @param string $link Link
968
     *
969
     * @return void
970
     */
971
    public function setLink($link)
972
    {
973
        $this->link = $link;
974
    }
975
976
    /**
977 11
     * Returns the link
978
     *
979 11
     * @return string
980 11
     */
981 11
    public function getLink()
982 11
    {
983 11
        return $this->link;
984 11
    }
985 1
986 1
    /**
987 11
     * Sets topEvent
988
     *
989
     * @param bool $topEvent TopEvent
990
     *
991
     * @return void
992
     */
993
    public function setTopEvent($topEvent)
994
    {
995
        $this->topEvent = $topEvent;
996
    }
997 1
998
    /**
999 1
     * Returns if topEvent is checked
1000 1
     *
1001
     * @return bool
1002
     */
1003
    public function getTopEvent()
1004
    {
1005
        return $this->topEvent;
1006
    }
1007 1
1008
    /**
1009 1
     * Returns max regisrations per user
1010
     *
1011
     * @return int
1012
     */
1013
    public function getMaxRegistrationsPerUser()
1014
    {
1015
        return $this->maxRegistrationsPerUser;
1016
    }
1017 2
1018
    /**
1019 2
     * Sets max registrations per user
1020
     *
1021
     * @param int $maxRegistrationsPerUser MaxRegistrationsPerUser
1022
     *
1023
     * @return void
1024
     */
1025
    public function setMaxRegistrationsPerUser($maxRegistrationsPerUser)
1026
    {
1027
        $this->maxRegistrationsPerUser = $maxRegistrationsPerUser;
1028
    }
1029 1
1030
    /**
1031 1
     * Adds an additionalImage
1032 1
     *
1033
     * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $additionalImage The Image
1034
     *
1035
     * @return void
1036
     */
1037
    public function addAdditionalImage(\TYPO3\CMS\Extbase\Domain\Model\FileReference $additionalImage)
1038
    {
1039
        $this->additionalImage->attach($additionalImage);
1040
    }
1041
1042 1
    /**
1043
     * Removes an additionalImage
1044 1
     *
1045 1
     * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $additionalImageToRemove The Image
1046
     *
1047
     * @return void
1048
     */
1049
    public function removeAdditionalImage(\TYPO3\CMS\Extbase\Domain\Model\FileReference $additionalImageToRemove)
1050
    {
1051
        $this->additionalImage->detach($additionalImageToRemove);
1052
    }
1053
1054 1
    /**
1055
     * Returns the additionalImage
1056 1
     *
1057 1
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $additionalImage
1058
     */
1059
    public function getAdditionalImage()
1060
    {
1061
        return $this->additionalImage;
1062
    }
1063
1064 1
    /**
1065
     * Sets the additionalImage
1066 1
     *
1067
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $additionalImage The Image
1068
     *
1069
     * @return void
1070
     */
1071
    public function setAdditionalImage(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $additionalImage)
1072
    {
1073
        $this->additionalImage = $additionalImage;
1074
    }
1075
1076 3
    /**
1077
     * Returns the organisator
1078 3
     *
1079 3
     * @return Organisator
1080
     */
1081
    public function getOrganisator()
1082
    {
1083
        return $this->organisator;
1084
    }
1085
1086 6
    /**
1087
     * Sets the organisator
1088 6
     *
1089
     * @param Organisator $organisator The organisator
1090
     *
1091
     * @return void
1092
     */
1093
    public function setOrganisator($organisator)
1094
    {
1095
        $this->organisator = $organisator;
1096
    }
1097
1098 6
    /**
1099
     * Returns notifyAdmin
1100 6
     *
1101 6
     * @return bool
1102
     */
1103
    public function getNotifyAdmin()
1104
    {
1105
        return $this->notifyAdmin;
1106
    }
1107
1108 27
    /**
1109
     * Sets notifyAdmin
1110 27
     *
1111
     * @param bool $notifyAdmin NotifyAdmin
1112
     *
1113
     * @return void
1114
     */
1115
    public function setNotifyAdmin($notifyAdmin)
1116
    {
1117
        $this->notifyAdmin = $notifyAdmin;
1118
    }
1119
1120 11
    /**
1121
     * Returns if notifyAdmin is set
1122 11
     *
1123 11
     * @return bool
1124
     */
1125
    public function getNotifyOrganisator()
1126
    {
1127
        return $this->notifyOrganisator;
1128
    }
1129
1130 27
    /**
1131
     * Sets notifyOrganisator
1132 27
     *
1133
     * @param bool $notifyOrganisator NotifyOrganisator
1134
     *
1135
     * @return void
1136
     */
1137
    public function setNotifyOrganisator($notifyOrganisator)
1138
    {
1139
        $this->notifyOrganisator = $notifyOrganisator;
1140
    }
1141
1142 11
    /**
1143
     * Sets enableCancel
1144 11
     *
1145 11
     * @param bool $enableCancel EnableCancel
1146
     *
1147
     * @return void
1148
     */
1149
    public function setEnableCancel($enableCancel)
1150
    {
1151
        $this->enableCancel = $enableCancel;
1152
    }
1153
1154 4
    /**
1155
     * Returns if registration can be canceled
1156 4
     *
1157 4
     * @return bool
1158
     */
1159
    public function getEnableCancel()
1160
    {
1161
        return $this->enableCancel;
1162
    }
1163
1164 5
    /**
1165
     * Sets the cancel deadline
1166 5
     *
1167
     * @param \DateTime $cancelDeadline CancelDeadline
1168
     *
1169
     * @return void
1170
     */
1171
    public function setCancelDeadline(\DateTime $cancelDeadline)
1172
    {
1173
        $this->cancelDeadline = $cancelDeadline;
1174
    }
1175
1176 4
    /**
1177
     * Returns the cancel deadline
1178 4
     *
1179 4
     * @return \DateTime
1180
     */
1181
    public function getCancelDeadline()
1182
    {
1183
        return $this->cancelDeadline;
1184
    }
1185
1186 4
    /**
1187
     * Returns if autoconfirmation is enabled
1188 4
     *
1189
     * @return bool
1190
     */
1191
    public function getEnableAutoconfirm()
1192
    {
1193
        return $this->enableAutoconfirm;
1194
    }
1195
1196 2
    /**
1197
     * Sets enable autoconfirm
1198 2
     *
1199
     * @param bool $enableAutoconfirm
1200
     * @return void
1201
     */
1202
    public function setEnableAutoconfirm($enableAutoconfirm)
1203
    {
1204
        $this->enableAutoconfirm = $enableAutoconfirm;
1205
    }
1206
1207 1
    /**
1208
     * Returns uniqueEmailCheck
1209 1
     *
1210 1
     * @return bool
1211
     */
1212
    public function getUniqueEmailCheck()
1213
    {
1214
        return $this->uniqueEmailCheck;
1215
    }
1216
1217 5
    /**
1218
     * Sets UniqueEmailCheck
1219 5
     *
1220
     * @param bool $uniqueEmailCheck
1221
     * @return void
1222
     */
1223
    public function setUniqueEmailCheck($uniqueEmailCheck)
1224
    {
1225
        $this->uniqueEmailCheck = $uniqueEmailCheck;
1226
    }
1227
1228 3
    /**
1229
     * Returns price options
1230 3
     *
1231 3
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
1232
     */
1233
    public function getPriceOptions()
1234
    {
1235
        return $this->priceOptions;
1236
    }
1237
1238
    /**
1239
     * Sets price options
1240 3
     *
1241
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $priceOptions
1242 3
     * @return void
1243 3
     */
1244
    public function setPriceOptions($priceOptions)
1245
    {
1246
        $this->priceOptions = $priceOptions;
1247
    }
1248
1249
    /**
1250
     * Adds a price option
1251
     *
1252 1
     * @param \DERHANSEN\SfEventMgt\Domain\Model\PriceOption $priceOption Price option
1253
     *
1254 1
     * @return void
1255 1
     */
1256
    public function addPriceOptions(\DERHANSEN\SfEventMgt\Domain\Model\PriceOption $priceOption)
1257
    {
1258
        $this->priceOptions->attach($priceOption);
1259
    }
1260
1261
    /**
1262 3
     * Removes a Registration
1263
     *
1264 3
     * @param \DERHANSEN\SfEventMgt\Domain\Model\PriceOption $priceOption Price option
1265 3
     *
1266 3
     * @return void
1267 3
     */
1268 2
    public function removePriceOptions(\DERHANSEN\SfEventMgt\Domain\Model\PriceOption $priceOption)
1269 2
    {
1270 2
        $this->priceOptions->detach($priceOption);
1271 3
    }
1272 3
1273 3
    /**
1274 3
     * Returns all active price options sorted by date ASC
1275
     *
1276
     * @return array
1277
     */
1278
    public function getActivePriceOptions()
1279
    {
1280
        $activePriceOptions = [];
1281
        if ($this->getPriceOptions()) {
1282 2
            $compareDate = new \DateTime('today midnight');
1283
            foreach ($this->getPriceOptions() as $priceOption) {
1284 2
                if ($priceOption->getValidUntil() >= $compareDate) {
1285 2
                    $activePriceOptions[$priceOption->getValidUntil()->getTimestamp()] = $priceOption;
1286
                }
1287 1
            }
1288
        }
1289
        ksort($activePriceOptions);
1290 1
1291
        return $activePriceOptions;
1292
    }
1293
1294
    /**
1295
     * Returns the current price of the event respecting possible price options
1296
     *
1297
     * @return float
1298
     */
1299 1
    public function getCurrentPrice()
1300
    {
1301 1
        $activePriceOptions = $this->getActivePriceOptions();
1302
        if (count($activePriceOptions) >= 1) {
1303
            // Sort active price options and return first element
1304
            return reset($activePriceOptions)->getPrice();
1305
        }
1306
        // Just return the price field
1307
        return $this->price;
1308
    }
1309
1310
    /**
1311 3
     * Returns registrationWaitlist
1312
     *
1313 3
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
1314 3
     */
1315
    public function getRegistrationWaitlist()
1316
    {
1317
        return $this->registrationWaitlist;
1318
    }
1319
1320
    /**
1321
     * Sets registrationWaitlist
1322
     *
1323 1
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $registration Registration
1324
     *
1325 1
     * @return void
1326 1
     */
1327
    public function setRegistrationWaitlist(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $registration)
1328
    {
1329
        $this->registrationWaitlist = $registration;
1330
    }
1331
1332
    /**
1333
     * Adds a Registration to the waitlist
1334
     *
1335 1
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration Registration
1336
     *
1337 1
     * @return void
1338 1
     */
1339
    public function addRegistrationWaitlist(\DERHANSEN\SfEventMgt\Domain\Model\Registration $registration)
1340
    {
1341
        $this->registrationWaitlist->attach($registration);
1342
    }
1343
1344
    /**
1345 3
     * Removes a Registration from the waitlist
1346
     *
1347 3
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registrationToRemove Registration
1348
     *
1349
     * @return void
1350
     */
1351
    public function removeRegistrationWaitlist(\DERHANSEN\SfEventMgt\Domain\Model\Registration $registrationToRemove)
1352
    {
1353
        $this->registrationWaitlist->detach($registrationToRemove);
1354
    }
1355
1356
    /**
1357
     * Returns, if cancellation for registrations of the event is possible
1358
     *
1359
     * @return bool
1360
     */
1361
    public function getCancellationPossible()
1362
    {
1363
        return ($this->getEnableCancel() && $this->getCancelDeadline() > new \DateTime()) ||
1364
            ($this->getEnableCancel() && $this->getCancelDeadline() === null);
1365
    }
1366
1367
    /**
1368
     * Returns speaker
1369
     *
1370
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
1371
     */
1372
    public function getSpeaker()
1373
    {
1374
        return $this->speaker;
1375
    }
1376
1377
    /**
1378
     * Sets speaker
1379
     *
1380
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $speaker
1381
     * @return void
1382
     */
1383
    public function setSpeaker($speaker)
1384
    {
1385
        $this->speaker = $speaker;
1386
    }
1387
1388
    /**
1389
     * Adds a speaker
1390
     *
1391
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Speaker $speaker
1392
     *
1393
     * @return void
1394
     */
1395
    public function addSpeaker(\DERHANSEN\SfEventMgt\Domain\Model\Speaker $speaker)
1396
    {
1397
        $this->speaker->attach($speaker);
1398
    }
1399
1400
    /**
1401
     * Removes a speaker
1402
     *
1403
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Speaker $speaker
1404
     *
1405
     * @return void
1406
     */
1407
    public function removeSpeaker(\DERHANSEN\SfEventMgt\Domain\Model\Speaker $speaker)
1408
    {
1409
        $this->speaker->detach($speaker);
1410
    }
1411
1412
    /**
1413
     * Returns registrationFields
1414
     *
1415
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
1416
     */
1417
    public function getRegistrationFields()
1418
    {
1419
        return $this->registrationFields;
1420
    }
1421
1422
    /**
1423
     * Sets registrationWaitlist
1424
     *
1425
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $registrationFields
1426
     *
1427
     * @return void
1428
     */
1429
    public function setRegistrationFields(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $registrationFields)
1430
    {
1431
        $this->registrationFields = $registrationFields;
1432
    }
1433
1434
    /**
1435
     * Adds a registrationField
1436
     *
1437
     * @param Field $registrationField
1438
     */
1439
    public function addRegistrationFields(Field $registrationField)
1440
    {
1441
        $this->registrationFields->attach($registrationField);
1442
    }
1443
1444
    /**
1445
     * Removed a registrationField
1446
     *
1447
     * @param Field $registrationField
1448
     */
1449
    public function removeRegistrationFields(Field $registrationField)
1450
    {
1451
        $this->registrationFields->detach($registrationField);
1452
    }
1453
1454
    /**
1455
     * Returns an array with registration field uids
1456
     *
1457
     * @return array
1458
     */
1459
    public function getRegistrationFieldsUids()
1460
    {
1461
        $result = [];
1462
        foreach ($this->registrationFields as $registrationField) {
1463
            $result[] = $registrationField->getUid();
1464
        }
1465
1466
        return $result;
1467
    }
1468
1469
    /**
1470
     * Returns an array with registration field uids and titles
1471
     * [uid => title]
1472
     *
1473
     * @return array
1474
     */
1475
    public function getRegistrationFieldUidsWithTitle()
1476
    {
1477
        $result = [];
1478
        foreach ($this->registrationFields as $registrationField) {
1479
            $result[$registrationField->getUid()] = $registrationField->getTitle();
1480
        }
1481
1482
        return $result;
1483
    }
1484
1485
    /**
1486
     * Special getter to return the amount of registrations that are saved to default language
1487
     * Required since TYPO3 9.5 (#82363)
1488
     *
1489
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
1490
     */
1491
    public function getRegistrations()
1492
    {
1493
        if ($GLOBALS['TSFE']->sys_language_uid > 0) {
1494
            return $this->getRegistrationsDefaultLanguage(false);
1495
        }
1496
1497
        return $this->registration;
1498
    }
1499
1500
    /**
1501
     * Special getter to return the amount of waitlist registrations that are saved to default language
1502
     * Required since TYPO3 9.5 (#82363)
1503
     *
1504
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
1505
     */
1506
    public function getRegistrationsWaitlist()
1507
    {
1508
        // Since TYPO3 9.5 (#82363)
1509
        if ($GLOBALS['TSFE']->sys_language_uid > 0) {
1510
            return $this->getRegistrationsDefaultLanguage(true);
1511
        }
1512
1513
        return $this->registrationWaitlist;
1514
    }
1515
1516
    /**
1517
     * Returns an objectStorage object holding all registrations in the default language.
1518
     * Ensures expected behavior of getRegistration() and getRegistrationWaitlist() since TYPO3 issue #82363
1519
     *
1520
     * @param bool $waitlist
1521
     * @return ObjectStorage
1522
     */
1523
    protected function getRegistrationsDefaultLanguage(bool $waitlist = false)
1524
    {
1525
        $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
1526
        $result = $objectManager->get(ObjectStorage::class);
1527
        $registrationRepository = $objectManager->get(RegistrationRepository::class);
1528
        $registrations = $registrationRepository->findByEventAndWaitlist($this, $waitlist);
1529
        foreach ($registrations as $registration) {
1530
            $result->attach($registration);
1531
        }
1532
1533
        return $result;
1534
    }
1535
1536
    /**
1537
     * Returns if the event ends on the same day
1538
     *
1539
     * @return bool
1540
     */
1541
    public function getEndsSameDay(): bool
1542
    {
1543
        if ($this->enddate !== null) {
1544
            return $this->startdate->format('d.m.Y') === $this->enddate->format('d.m.Y');
1545
        }
1546
1547
        return true;
1548
    }
1549
}
1550