Completed
Push — development ( 9d105e...bf3399 )
by Torben
04:26
created

Event::getRegistrationFieldUidsWithTitle()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

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