Completed
Push — development ( 46781f...eabfd0 )
by Torben
04:00
created

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