Completed
Push — master ( 582c54...9e2bdc )
by Torben
07:45 queued 04:37
created

Event::setRoom()   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 1
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 362
    /**
278
     * Unique e-mail check
279 362
     *
280 362
     * @var bool
281 362
     */
282 362
    protected $uniqueEmailCheck = false;
283 362
284 362
    /**
285 362
     * Price options
286 362
     *
287 362
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\DERHANSEN\SfEventMgt\Domain\Model\PriceOption>
288
     * @cascade remove
289
     * @lazy
290
     */
291
    protected $priceOptions = null;
292
293
    /**
294 10
     * Speaker
295
     *
296 10
     * @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 2
        $this->category = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
307
        $this->related = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
308 2
        $this->registration = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
309 2
        $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 2
    }
317
318 2
    /**
319
     * Get timestamp
320
     *
321
     * @return \DateTime
322
     */
323
    public function getTstamp()
324
    {
325
        return $this->tstamp;
326
    }
327
328 2
    /**
329
     * Set time stamp
330 2
     *
331 2
     * @param \DateTime $tstamp time stamp
332
     */
333
    public function setTstamp($tstamp)
334
    {
335
        $this->tstamp = $tstamp;
336
    }
337
338 2
    /**
339
     * Returns the title
340 2
     *
341
     * @return string $title
342
     */
343
    public function getTitle()
344
    {
345
        return $this->title;
346
    }
347
348
    /**
349
     * Sets the title
350 2
     *
351
     * @param string $title Title
352 2
     *
353 2
     * @return void
354
     */
355
    public function setTitle($title)
356
    {
357
        $this->title = $title;
358
    }
359
360 2
    /**
361
     * Returns the teaser
362 2
     *
363
     * @return string
364
     */
365
    public function getTeaser()
366
    {
367
        return $this->teaser;
368
    }
369
370
    /**
371
     * Sets the teaser
372 2
     *
373
     * @param string $teaser Teaser
374 2
     *
375 2
     * @return void
376
     */
377
    public function setTeaser($teaser)
378
    {
379
        $this->teaser = $teaser;
380
    }
381
382 22
    /**
383
     * Returns the description
384 22
     *
385
     * @return string $description
386
     */
387
    public function getDescription()
388
    {
389
        return $this->description;
390
    }
391
392
    /**
393
     * Sets the description
394 22
     *
395
     * @param string $description Description
396 22
     *
397 22
     * @return void
398
     */
399
    public function setDescription($description)
400
    {
401
        $this->description = $description;
402
    }
403
404 2
    /**
405
     * Returns the program
406 2
     *
407
     * @return string $program
408
     */
409
    public function getProgram()
410
    {
411
        return $this->program;
412
    }
413
414
    /**
415
     * Sets the program
416 2
     *
417
     * @param string $program The program
418 2
     *
419 2
     * @return void
420
     */
421
    public function setProgram($program)
422
    {
423
        $this->program = $program;
424
    }
425
426 28
    /**
427
     * Returns the startdate
428 28
     *
429
     * @return \DateTime $startdate
430
     */
431
    public function getStartdate()
432
    {
433
        return $this->startdate;
434
    }
435
436
    /**
437
     * Sets the startdate
438 26
     *
439
     * @param \DateTime $startdate Startdate
440 26
     *
441 26
     * @return void
442
     */
443
    public function setStartdate(\DateTime $startdate)
444
    {
445
        $this->startdate = $startdate;
446
    }
447
448 2
    /**
449
     * Returns the enddate
450 2
     *
451
     * @return \DateTime $enddate
452
     */
453
    public function getEnddate()
454
    {
455
        return $this->enddate;
456
    }
457
458
    /**
459
     * Sets the enddate
460 6
     *
461
     * @param \DateTime $enddate Enddate
462 6
     *
463 6
     * @return void
464
     */
465
    public function setEnddate(\DateTime $enddate)
466
    {
467
        $this->enddate = $enddate;
468
    }
469
470 2
    /**
471
     * Returns the participants
472 2
     *
473
     * @return int $participants
474
     */
475
    public function getMaxParticipants()
476
    {
477
        return $this->maxParticipants;
478
    }
479
480
    /**
481
     * Sets the participants
482 2
     *
483
     * @param int $participants Participants
484 2
     *
485 2
     * @return void
486
     */
487
    public function setMaxParticipants($participants)
488
    {
489
        $this->maxParticipants = $participants;
490
    }
491
492 8
    /**
493
     * Returns the price
494 8
     *
495
     * @return float $price
496
     */
497
    public function getPrice()
498
    {
499
        return $this->price;
500
    }
501
502
    /**
503 6
     * Sets the price
504
     *
505 6
     * @param float $price Price
506 6
     *
507
     * @return void
508
     */
509
    public function setPrice($price)
510
    {
511
        $this->price = $price;
512
    }
513 6
514
    /**
515 6
     * Returns the currency
516
     *
517
     * @return string $currency
518
     */
519
    public function getCurrency()
520
    {
521
        return $this->currency;
522
    }
523
524 2
    /**
525
     * Sets the currency
526 2
     *
527 2
     * @param string $currency Currency
528
     *
529
     * @return void
530
     */
531
    public function setCurrency($currency)
532
    {
533
        $this->currency = $currency;
534 4
    }
535
536 4
    /**
537
     * Returns if payment is enabled
538
     *
539
     * @return bool
540
     */
541
    public function getEnablePayment()
542
    {
543
        return $this->enablePayment;
544
    }
545 2
546
    /**
547 2
     * Sets enablePayment
548 2
     *
549
     * @param bool $enablePayment
550
     * @return void
551
     */
552
    public function setEnablePayment($enablePayment)
553
    {
554
        $this->enablePayment = $enablePayment;
555
    }
556
557 2
    /**
558
     * Returns if payment methods should be restricted
559 2
     *
560 2
     * @return bool
561
     */
562
    public function getRestrictPaymentMethods()
563
    {
564
        return $this->restrictPaymentMethods;
565
    }
566
567
    /**
568
     * Sets if payment methods should be restricted
569 2
     *
570
     * @param bool $restrictPaymentMethods
571 2
     * @return void
572 2
     */
573
    public function setRestrictPaymentMethods($restrictPaymentMethods)
574
    {
575
        $this->restrictPaymentMethods = $restrictPaymentMethods;
576
    }
577
578
    /**
579 2
     * Returns selected payment methods
580
     *
581 2
     * @return string
582
     */
583
    public function getSelectedPaymentMethods()
584
    {
585
        return $this->selectedPaymentMethods;
586
    }
587
588
    /**
589
     * Sets selected payment methods
590
     *
591 6
     * @param string $selectedPaymentMethods
592
     * @return void
593 6
     */
594 6
    public function setSelectedPaymentMethods($selectedPaymentMethods)
595
    {
596
        $this->selectedPaymentMethods = $selectedPaymentMethods;
597
    }
598
599
    /**
600
     * Adds a Category
601 4
     *
602
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Category $category Category
603 4
     *
604
     * @return void
605
     */
606
    public function addCategory(\DERHANSEN\SfEventMgt\Domain\Model\Category $category)
607
    {
608
        $this->category->attach($category);
609
    }
610
611
    /**
612 6
     * Removes a Category
613
     *
614 6
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Category $categoryToRemove The Category to be removed
615 6
     *
616
     * @return void
617
     */
618
    public function removeCategory(\DERHANSEN\SfEventMgt\Domain\Model\Category $categoryToRemove)
619
    {
620
        $this->category->detach($categoryToRemove);
621
    }
622
623 2
    /**
624
     * Returns the category
625 2
     *
626 2
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
627
     */
628
    public function getCategory()
629
    {
630
        return $this->category;
631
    }
632
633
    /**
634 2
     * Sets the category
635
     *
636 2
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $category Category
637 2
     *
638
     * @return void
639
     */
640
    public function setCategory(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $category)
641
    {
642
        $this->category = $category;
643
    }
644
645
    /**
646 4
     * Returns related events
647
     *
648 4
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
649 4
     */
650
    public function getRelated()
651
    {
652
        return $this->related;
653
    }
654
655
    /**
656
     * Sets related events
657
     *
658 2
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $related
659
     * @return void
660 2
     */
661 2
    public function setRelated($related)
662
    {
663
        $this->related = $related;
664
    }
665
666
    /**
667
     * Adds a related event
668 24
     *
669
     * @param Event $event
670 24
     * @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 18
     * @param Event $event
681
     * @return void
682 18
     */
683 18
    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 2
     *
693
     * @return void
694 2
     */
695 2
    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 2
     *
705
     * @return void
706 2
     */
707 2
    public function removeRegistration(\DERHANSEN\SfEventMgt\Domain\Model\Registration $registrationToRemove)
708
    {
709
        $this->registration->detach($registrationToRemove);
710
    }
711
712
    /**
713
     * Returns the Registration
714 2
     *
715
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $registration
716 2
     */
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 6
     *
727
     * @return void
728 6
     */
729 6
    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 4
     *
739
     * @return void
740 4
     */
741 4
    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 2
     *
751
     * @return void
752 2
     */
753 2
    public function removeImage(\TYPO3\CMS\Extbase\Domain\Model\FileReference $imageToRemove)
754
    {
755
        $this->image->detach($imageToRemove);
756
    }
757
758
    /**
759
     * Returns the image
760 2
     *
761
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $image
762 2
     */
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 6
     *
773
     * @return void
774 6
     */
775 6
    public function setImage(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $image)
776
    {
777
        $this->image = $image;
778
    }
779
780
    /**
781
     * Adds a file
782 4
     *
783
     * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $file File
784 4
     *
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 2
     *
795
     * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $fileToRemove File
796 2
     *
797 2
     * @return void
798
     */
799
    public function removeFiles(\TYPO3\CMS\Extbase\Domain\Model\FileReference $fileToRemove)
800
    {
801
        $this->files->detach($fileToRemove);
802
    }
803
804 20
    /**
805
     * Returns the files
806 20
     *
807 20
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $files
808 6
     */
809 6
    public function getFiles()
810 20
    {
811 20
        return $this->files;
812 2
    }
813 2
814 20
    /**
815 20
     * Sets the files
816 20
     *
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 10
    }
825
826 10
    /**
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 2
        }
837
        $deadlineNotReached = true;
838 2
        if ($this->getRegistrationDeadline() != null && $this->getRegistrationDeadline() <= new \DateTime()) {
839 2
            $deadlineNotReached = false;
840
        }
841
842
        return ($this->getStartdate() > new \DateTime()) &&
843
        ($maxParticipantsNotReached || !$maxParticipantsNotReached && $this->enableWaitlist) &&
844
        $this->getEnableRegistration() && $deadlineNotReached;
845
    }
846 2
847
    /**
848 2
     * 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 20
     * Sets the location
859
     *
860 20
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Location $location Location
861 20
     *
862
     * @return void
863
     */
864
    public function setLocation($location)
865
    {
866
        $this->location = $location;
867
    }
868 16
869
    /**
870 16
     * Returns the location
871
     *
872
     * @return \DERHANSEN\SfEventMgt\Domain\Model\Location
873
     */
874
    public function getLocation()
875
    {
876
        return $this->location;
877
    }
878 8
879
    /**
880 8
     * Returns the room
881
     *
882
     * @return string
883
     */
884
    public function getRoom()
885
    {
886
        return $this->room;
887
    }
888
889 10
    /**
890
     * Sets the room
891 10
     *
892 10
     * @param string $room
893
     */
894
    public function setRoom($room)
895
    {
896
        $this->room = $room;
897
    }
898
899
    /**
900
     * Sets enableRegistration
901 6
     *
902
     * @param bool $enableRegistration EnableRegistration
903 6
     *
904 6
     * @return void
905
     */
906
    public function setEnableRegistration($enableRegistration)
907
    {
908
        $this->enableRegistration = $enableRegistration;
909
    }
910
911 22
    /**
912
     * Returns if registration is enabled
913 22
     *
914
     * @return bool
915
     */
916
    public function getEnableRegistration()
917
    {
918
        return $this->enableRegistration;
919
    }
920
921
    /**
922
     * Returns enableWaitlist
923 24
     *
924
     * @return bool
925 24
     */
926 24
    public function getEnableWaitlist()
927
    {
928
        return $this->enableWaitlist;
929
    }
930
931
    /**
932
     * Sets enableWaitlist
933 2
     *
934
     * @param bool $enableWaitlist
935 2
     * @return void
936
     */
937
    public function setEnableWaitlist($enableWaitlist)
938
    {
939
        $this->enableWaitlist = $enableWaitlist;
940
    }
941
942
    /**
943 2
     * Sets the registration deadline
944
     *
945 2
     * @param \DateTime $registrationDeadline RegistrationDeadline
946
     *
947
     * @return void
948
     */
949
    public function setRegistrationDeadline(\DateTime $registrationDeadline)
950
    {
951
        $this->registrationDeadline = $registrationDeadline;
952
    }
953 2
954
    /**
955 2
     * Returns the registration deadline
956
     *
957
     * @return \DateTime
958
     */
959
    public function getRegistrationDeadline()
960
    {
961
        return $this->registrationDeadline;
962
    }
963 2
964
    /**
965 2
     * 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 22
     * Returns the link
978
     *
979 22
     * @return string
980 22
     */
981 22
    public function getLink()
982 22
    {
983 22
        return $this->link;
984 22
    }
985 2
986 2
    /**
987 22
     * 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 2
998
    /**
999 2
     * Returns if topEvent is checked
1000 2
     *
1001
     * @return bool
1002
     */
1003
    public function getTopEvent()
1004
    {
1005
        return $this->topEvent;
1006
    }
1007 2
1008
    /**
1009 2
     * Returns max regisrations per user
1010
     *
1011
     * @return int
1012
     */
1013
    public function getMaxRegistrationsPerUser()
1014
    {
1015
        return $this->maxRegistrationsPerUser;
1016
    }
1017 4
1018
    /**
1019 4
     * 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 2
1030
    /**
1031 2
     * Adds an additionalImage
1032 2
     *
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 2
    /**
1043
     * Removes an additionalImage
1044 2
     *
1045 2
     * @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 2
    /**
1055
     * Returns the additionalImage
1056 2
     *
1057 2
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $additionalImage
1058
     */
1059
    public function getAdditionalImage()
1060
    {
1061
        return $this->additionalImage;
1062
    }
1063
1064 2
    /**
1065
     * Sets the additionalImage
1066 2
     *
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 6
    /**
1077
     * Returns the organisator
1078 6
     *
1079 6
     * @return Organisator
1080
     */
1081
    public function getOrganisator()
1082
    {
1083
        return $this->organisator;
1084
    }
1085
1086 12
    /**
1087
     * Sets the organisator
1088 12
     *
1089
     * @param Organisator $organisator The organisator
1090
     *
1091
     * @return void
1092
     */
1093
    public function setOrganisator($organisator)
1094
    {
1095
        $this->organisator = $organisator;
1096
    }
1097
1098 12
    /**
1099
     * Returns notifyAdmin
1100 12
     *
1101 12
     * @return bool
1102
     */
1103
    public function getNotifyAdmin()
1104
    {
1105
        return $this->notifyAdmin;
1106
    }
1107
1108 54
    /**
1109
     * Sets notifyAdmin
1110 54
     *
1111
     * @param bool $notifyAdmin NotifyAdmin
1112
     *
1113
     * @return void
1114
     */
1115
    public function setNotifyAdmin($notifyAdmin)
1116
    {
1117
        $this->notifyAdmin = $notifyAdmin;
1118
    }
1119
1120 22
    /**
1121
     * Returns if notifyAdmin is set
1122 22
     *
1123 22
     * @return bool
1124
     */
1125
    public function getNotifyOrganisator()
1126
    {
1127
        return $this->notifyOrganisator;
1128
    }
1129
1130 54
    /**
1131
     * Sets notifyOrganisator
1132 54
     *
1133
     * @param bool $notifyOrganisator NotifyOrganisator
1134
     *
1135
     * @return void
1136
     */
1137
    public function setNotifyOrganisator($notifyOrganisator)
1138
    {
1139
        $this->notifyOrganisator = $notifyOrganisator;
1140
    }
1141
1142 22
    /**
1143
     * Sets enableCancel
1144 22
     *
1145 22
     * @param bool $enableCancel EnableCancel
1146
     *
1147
     * @return void
1148
     */
1149
    public function setEnableCancel($enableCancel)
1150
    {
1151
        $this->enableCancel = $enableCancel;
1152
    }
1153
1154 8
    /**
1155
     * Returns if registration can be canceled
1156 8
     *
1157 8
     * @return bool
1158
     */
1159
    public function getEnableCancel()
1160
    {
1161
        return $this->enableCancel;
1162
    }
1163
1164 10
    /**
1165
     * Sets the cancel deadline
1166 10
     *
1167
     * @param \DateTime $cancelDeadline CancelDeadline
1168
     *
1169
     * @return void
1170
     */
1171
    public function setCancelDeadline(\DateTime $cancelDeadline)
1172
    {
1173
        $this->cancelDeadline = $cancelDeadline;
1174
    }
1175
1176 8
    /**
1177
     * Returns the cancel deadline
1178 8
     *
1179 8
     * @return \DateTime
1180
     */
1181
    public function getCancelDeadline()
1182
    {
1183
        return $this->cancelDeadline;
1184
    }
1185
1186 8
    /**
1187
     * Returns if autoconfirmation is enabled
1188 8
     *
1189
     * @return bool
1190
     */
1191
    public function getEnableAutoconfirm()
1192
    {
1193
        return $this->enableAutoconfirm;
1194
    }
1195
1196 4
    /**
1197
     * Sets enable autoconfirm
1198 4
     *
1199
     * @param bool $enableAutoconfirm
1200
     * @return void
1201
     */
1202
    public function setEnableAutoconfirm($enableAutoconfirm)
1203
    {
1204
        $this->enableAutoconfirm = $enableAutoconfirm;
1205
    }
1206
1207 2
    /**
1208
     * Returns uniqueEmailCheck
1209 2
     *
1210 2
     * @return bool
1211
     */
1212
    public function getUniqueEmailCheck()
1213
    {
1214
        return $this->uniqueEmailCheck;
1215
    }
1216
1217 10
    /**
1218
     * Sets UniqueEmailCheck
1219 10
     *
1220
     * @param bool $uniqueEmailCheck
1221
     * @return void
1222
     */
1223
    public function setUniqueEmailCheck($uniqueEmailCheck)
1224
    {
1225
        $this->uniqueEmailCheck = $uniqueEmailCheck;
1226
    }
1227
1228 6
    /**
1229
     * Returns price options
1230 6
     *
1231 6
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
1232
     */
1233
    public function getPriceOptions()
1234
    {
1235
        return $this->priceOptions;
1236
    }
1237
1238
    /**
1239
     * Sets price options
1240 6
     *
1241
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $priceOptions
1242 6
     * @return void
1243 6
     */
1244
    public function setPriceOptions($priceOptions)
1245
    {
1246
        $this->priceOptions = $priceOptions;
1247
    }
1248
1249
    /**
1250
     * Adds a price option
1251
     *
1252 2
     * @param \DERHANSEN\SfEventMgt\Domain\Model\PriceOption $priceOption Price option
1253
     *
1254 2
     * @return void
1255 2
     */
1256
    public function addPriceOptions(\DERHANSEN\SfEventMgt\Domain\Model\PriceOption $priceOption)
1257
    {
1258
        $this->priceOptions->attach($priceOption);
1259
    }
1260
1261
    /**
1262 6
     * Removes a Registration
1263
     *
1264 6
     * @param \DERHANSEN\SfEventMgt\Domain\Model\PriceOption $priceOption Price option
1265 6
     *
1266 6
     * @return void
1267 6
     */
1268 4
    public function removePriceOptions(\DERHANSEN\SfEventMgt\Domain\Model\PriceOption $priceOption)
1269 4
    {
1270 4
        $this->priceOptions->detach($priceOption);
1271 6
    }
1272 6
1273 6
    /**
1274 6
     * 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 4
            $compareDate = new \DateTime('today midnight');
1283
            foreach ($this->getPriceOptions() as $priceOption) {
1284 4
                if ($priceOption->getValidUntil() >= $compareDate) {
1285 4
                    $activePriceOptions[$priceOption->getValidUntil()->getTimestamp()] = $priceOption;
1286
                }
1287 2
            }
1288
        }
1289
        ksort($activePriceOptions);
1290 2
1291
        return $activePriceOptions;
1292
    }
1293
1294
    /**
1295
     * Returns the current price of the event respecting possible price options
1296
     *
1297
     * @return float
1298
     */
1299 2
    public function getCurrentPrice()
1300
    {
1301 2
        $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 6
     * Returns registrationWaitlist
1312
     *
1313 6
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
1314 6
     */
1315
    public function getRegistrationWaitlist()
1316
    {
1317
        return $this->registrationWaitlist;
1318
    }
1319
1320
    /**
1321
     * Sets registrationWaitlist
1322
     *
1323 2
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $registration Registration
1324
     *
1325 2
     * @return void
1326 2
     */
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 2
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration Registration
1336
     *
1337 2
     * @return void
1338 2
     */
1339
    public function addRegistrationWaitlist(\DERHANSEN\SfEventMgt\Domain\Model\Registration $registration)
1340
    {
1341
        $this->registrationWaitlist->attach($registration);
1342
    }
1343
1344
    /**
1345 6
     * Removes a Registration from the waitlist
1346
     *
1347 6
     * @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