Completed
Push — development ( 3c5a2a...702ac8 )
by Torben
04:13
created

Event::getYoutube()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
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<\TYPO3\CMS\Extbase\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 boolean
504
     */
505 3
    public function getEnablePayment()
506 3
    {
507
        return $this->enablePayment;
508
    }
509
510
    /**
511
     * Sets enablePayment
512
     *
513 3
     * @param boolean $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 boolean
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 boolean $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 \TYPO3\CMS\Extbase\Domain\Model\Category $category Category
567
     *
568
     * @return void
569 1
     */
570
    public function addCategory(\TYPO3\CMS\Extbase\Domain\Model\Category $category)
571 1
    {
572 1
        $this->category->attach($category);
573
    }
574
575
    /**
576
     * Removes a Category
577
     *
578
     * @param \TYPO3\CMS\Extbase\Domain\Model\Category $categoryToRemove The Category to be removed
579 1
     *
580
     * @return void
581 1
     */
582
    public function removeCategory(\TYPO3\CMS\Extbase\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
        return ($this->getStartdate() > new \DateTime()) &&
806 10
        ($maxParticipantsNotReached || !$maxParticipantsNotReached && $this->enableWaitlist) &&
807 10
        $this->getEnableRegistration() && $deadlineNotReached;
808 3
    }
809 3
810 10
    /**
811 10
     * Returns the amount of free places
812 1
     *
813 1
     * @return int
814 10
     */
815 10
    public function getFreePlaces()
816 10
    {
817
        return $this->maxParticipants - $this->getRegistration()->count();
818
    }
819
820
    /**
821
     * Sets the location
822
     *
823
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Location $location Location
824 5
     *
825
     * @return void
826 5
     */
827
    public function setLocation($location)
828
    {
829
        $this->location = $location;
830
    }
831
832
    /**
833
     * Returns the location
834
     *
835
     * @return \DERHANSEN\SfEventMgt\Domain\Model\Location
836 1
     */
837
    public function getLocation()
838 1
    {
839 1
        return $this->location;
840
    }
841
842
    /**
843
     * Sets enableRegistration
844
     *
845
     * @param bool $enableRegistration EnableRegistration
846 1
     *
847
     * @return void
848 1
     */
849
    public function setEnableRegistration($enableRegistration)
850
    {
851
        $this->enableRegistration = $enableRegistration;
852
    }
853
854
    /**
855
     * Returns if registration is enabled
856
     *
857
     * @return bool
858 10
     */
859
    public function getEnableRegistration()
860 10
    {
861 10
        return $this->enableRegistration;
862
    }
863
864
    /**
865
     * Returns enableWaitlist
866
     *
867
     * @return boolean
868 8
     */
869
    public function getEnableWaitlist()
870 8
    {
871
        return $this->enableWaitlist;
872
    }
873
874
    /**
875
     * Sets enableWaitlist
876
     *
877
     * @param boolean $enableWaitlist
878 4
     * @return void
879
     */
880 4
    public function setEnableWaitlist($enableWaitlist)
881
    {
882
        $this->enableWaitlist = $enableWaitlist;
883
    }
884
885
    /**
886
     * Sets the registration deadline
887
     *
888
     * @param \DateTime $registrationDeadline RegistrationDeadline
889 5
     *
890
     * @return void
891 5
     */
892 5
    public function setRegistrationDeadline(\DateTime $registrationDeadline)
893
    {
894
        $this->registrationDeadline = $registrationDeadline;
895
    }
896
897
    /**
898
     * Returns the registration deadline
899
     *
900
     * @return \DateTime
901 3
     */
902
    public function getRegistrationDeadline()
903 3
    {
904 3
        return $this->registrationDeadline;
905
    }
906
907
    /**
908
     * Sets the link
909
     *
910
     * @param string $link Link
911 11
     *
912
     * @return void
913 11
     */
914
    public function setLink($link)
915
    {
916
        $this->link = $link;
917
    }
918
919
    /**
920
     * Returns the link
921
     *
922
     * @return string
923 12
     */
924
    public function getLink()
925 12
    {
926 12
        return $this->link;
927
    }
928
929
    /**
930
     * Returns the uri of the link
931
     *
932
     * @return string
933 1
     */
934
    public function getLinkUrl()
935 1
    {
936
        return $this->getLinkPart(0);
937
    }
938
939
    /**
940
     * Returns the target of the link
941
     *
942
     * @return string
943 1
     */
944
    public function getLinkTarget()
945 1
    {
946
        return $this->getLinkPart(1);
947
    }
948
949
    /**
950
     * Returns the title of the link
951
     *
952
     * @return string
953 1
     */
954
    public function getLinkTitle()
955 1
    {
956
        return $this->getLinkPart(3);
957
    }
958
959
    /**
960
     * Splits link to an array respection that a title with more than one word is
961
     * surrounded by quotation marks. Returns part of the link for usage in fluid
962
     * viewhelpers.
963 1
     *
964
     * @param int $part The part
965 1
     *
966
     * @return string
967
     */
968
    public function getLinkPart($part)
969
    {
970
        $linkArray = str_getcsv($this->link, ' ', '"');
971
        $ret = '';
972
        if (count($linkArray) >= $part) {
973
            $ret = $linkArray[$part];
974
        }
975
        if ($ret === '-') {
976
            $ret = '';
977 11
        }
978
        return $ret;
979 11
    }
980 11
981 11
    /**
982 11
     * Sets topEvent
983 11
     *
984 11
     * @param bool $topEvent TopEvent
985 1
     *
986 1
     * @return void
987 11
     */
988
    public function setTopEvent($topEvent)
989
    {
990
        $this->topEvent = $topEvent;
991
    }
992
993
    /**
994
     * Returns if topEvent is checked
995
     *
996
     * @return bool
997 1
     */
998
    public function getTopEvent()
999 1
    {
1000 1
        return $this->topEvent;
1001
    }
1002
1003
    /**
1004
     * Returns max regisrations per user
1005
     *
1006
     * @return int
1007 1
     */
1008
    public function getMaxRegistrationsPerUser()
1009 1
    {
1010
        return $this->maxRegistrationsPerUser;
1011
    }
1012
1013
    /**
1014
     * Sets max registrations per user
1015
     *
1016
     * @param int $maxRegistrationsPerUser MaxRegistrationsPerUser
1017 2
     *
1018
     * @return void
1019 2
     */
1020
    public function setMaxRegistrationsPerUser($maxRegistrationsPerUser)
1021
    {
1022
        $this->maxRegistrationsPerUser = $maxRegistrationsPerUser;
1023
    }
1024
1025
1026
    /**
1027
     * Adds an additionalImage
1028
     *
1029 1
     * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $additionalImage The Image
1030
     *
1031 1
     * @return void
1032 1
     */
1033
    public function addAdditionalImage(\TYPO3\CMS\Extbase\Domain\Model\FileReference $additionalImage)
1034
    {
1035
        $this->additionalImage->attach($additionalImage);
1036
    }
1037
1038
    /**
1039
     * Removes an additionalImage
1040
     *
1041
     * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $additionalImageToRemove The Image
1042 1
     *
1043
     * @return void
1044 1
     */
1045 1
    public function removeAdditionalImage(\TYPO3\CMS\Extbase\Domain\Model\FileReference $additionalImageToRemove)
1046
    {
1047
        $this->additionalImage->detach($additionalImageToRemove);
1048
    }
1049
1050
    /**
1051
     * Returns the additionalImage
1052
     *
1053
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $additionalImage
1054 1
     */
1055
    public function getAdditionalImage()
1056 1
    {
1057 1
        return $this->additionalImage;
1058
    }
1059
1060
    /**
1061
     * Sets the additionalImage
1062
     *
1063
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $additionalImage The Image
1064 1
     *
1065
     * @return void
1066 1
     */
1067
    public function setAdditionalImage(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $additionalImage)
1068
    {
1069
        $this->additionalImage = $additionalImage;
1070
    }
1071
1072
    /**
1073
     * Returns the organisator
1074
     *
1075
     * @return Organisator
1076 3
     */
1077
    public function getOrganisator()
1078 3
    {
1079 3
        return $this->organisator;
1080
    }
1081
1082
    /**
1083
     * Sets the organisator
1084
     *
1085
     * @param Organisator $organisator The organisator
1086 6
     *
1087
     * @return void
1088 6
     */
1089
    public function setOrganisator($organisator)
1090
    {
1091
        $this->organisator = $organisator;
1092
    }
1093
1094
    /**
1095
     * Returns notifyAdmin
1096
     *
1097
     * @return bool
1098 6
     */
1099
    public function getNotifyAdmin()
1100 6
    {
1101 6
        return $this->notifyAdmin;
1102
    }
1103
1104
    /**
1105
     * Sets notifyAdmin
1106
     *
1107
     * @param bool $notifyAdmin NotifyAdmin
1108 27
     *
1109
     * @return void
1110 27
     */
1111
    public function setNotifyAdmin($notifyAdmin)
1112
    {
1113
        $this->notifyAdmin = $notifyAdmin;
1114
    }
1115
1116
    /**
1117
     * Returns if notifyAdmin is set
1118
     *
1119
     * @return bool
1120 11
     */
1121
    public function getNotifyOrganisator()
1122 11
    {
1123 11
        return $this->notifyOrganisator;
1124
    }
1125
1126
    /**
1127
     * Sets notifyOrganisator
1128
     *
1129
     * @param bool $notifyOrganisator NotifyOrganisator
1130 27
     *
1131
     * @return void
1132 27
     */
1133
    public function setNotifyOrganisator($notifyOrganisator)
1134
    {
1135
        $this->notifyOrganisator = $notifyOrganisator;
1136
    }
1137
1138
    /**
1139
     * Sets enableCancel
1140
     *
1141
     * @param bool $enableCancel EnableCancel
1142 11
     *
1143
     * @return void
1144 11
     */
1145 11
    public function setEnableCancel($enableCancel)
1146
    {
1147
        $this->enableCancel = $enableCancel;
1148
    }
1149
1150
    /**
1151
     * Returns if registration can be canceled
1152
     *
1153
     * @return bool
1154 4
     */
1155
    public function getEnableCancel()
1156 4
    {
1157 4
        return $this->enableCancel;
1158
    }
1159
1160
    /**
1161
     * Sets the cancel deadline
1162
     *
1163
     * @param \DateTime $cancelDeadline CancelDeadline
1164 5
     *
1165
     * @return void
1166 5
     */
1167
    public function setCancelDeadline(\DateTime $cancelDeadline)
1168
    {
1169
        $this->cancelDeadline = $cancelDeadline;
1170
    }
1171
1172
    /**
1173
     * Returns the cancel deadline
1174
     *
1175
     * @return \DateTime
1176 4
     */
1177
    public function getCancelDeadline()
1178 4
    {
1179 4
        return $this->cancelDeadline;
1180
    }
1181
1182
    /**
1183
     * Returns if autoconfirmation is enabled
1184
     *
1185
     * @return bool
1186 4
     */
1187
    public function getEnableAutoconfirm()
1188 4
    {
1189
        return $this->enableAutoconfirm;
1190
    }
1191
1192
    /**
1193
     * Sets enable autoconfirm
1194
     *
1195
     * @param bool $enableAutoconfirm
1196 2
     * @return void
1197
     */
1198 2
    public function setEnableAutoconfirm($enableAutoconfirm)
1199
    {
1200
        $this->enableAutoconfirm = $enableAutoconfirm;
1201
    }
1202
1203
    /**
1204
     * Returns uniqueEmailCheck
1205
     *
1206
     * @return boolean
1207 1
     */
1208
    public function getUniqueEmailCheck()
1209 1
    {
1210 1
        return $this->uniqueEmailCheck;
1211
    }
1212
1213
    /**
1214
     * Sets UniqueEmailCheck
1215
     *
1216
     * @param boolean $uniqueEmailCheck
1217 5
     * @return void
1218
     */
1219 5
    public function setUniqueEmailCheck($uniqueEmailCheck)
1220
    {
1221
        $this->uniqueEmailCheck = $uniqueEmailCheck;
1222
    }
1223
1224
    /**
1225
     * Returns price options
1226
     *
1227
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
1228 3
     */
1229
    public function getPriceOptions()
1230 3
    {
1231 3
        return $this->priceOptions;
1232
    }
1233
1234
    /**
1235
     * Sets price options
1236
     *
1237
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $priceOptions
1238
     * @return void
1239
     */
1240 3
    public function setPriceOptions($priceOptions)
1241
    {
1242 3
        $this->priceOptions = $priceOptions;
1243 3
    }
1244
1245
    /**
1246
     * Adds a price option
1247
     *
1248
     * @param \DERHANSEN\SfEventMgt\Domain\Model\PriceOption $priceOption Price option
1249
     *
1250
     * @return void
1251
     */
1252 1
    public function addPriceOptions(\DERHANSEN\SfEventMgt\Domain\Model\PriceOption $priceOption)
1253
    {
1254 1
        $this->priceOptions->attach($priceOption);
1255 1
    }
1256
1257
    /**
1258
     * Removes a Registration
1259
     *
1260
     * @param \DERHANSEN\SfEventMgt\Domain\Model\PriceOption $priceOption Price option
1261
     *
1262 3
     * @return void
1263
     */
1264 3
    public function removePriceOptions(\DERHANSEN\SfEventMgt\Domain\Model\PriceOption $priceOption)
1265 3
    {
1266 3
        $this->priceOptions->detach($priceOption);
1267 3
    }
1268 2
1269 2
    /**
1270 2
     * Returns all active price options sorted by date ASC
1271 3
     *
1272 3
     * @return array
1273 3
     */
1274 3
    public function getActivePriceOptions()
1275
    {
1276
        $activePriceOptions = [];
1277
        if ($this->getPriceOptions()) {
1278
            $compareDate = new \DateTime('today midnight');
1279
            foreach ($this->getPriceOptions() as $priceOption) {
1280
                if ($priceOption->getValidUntil() >= $compareDate) {
1281
                    $activePriceOptions[$priceOption->getValidUntil()->getTimestamp()] = $priceOption;
1282 2
                }
1283
            }
1284 2
        }
1285 2
        ksort($activePriceOptions);
1286
        return $activePriceOptions;
1287 1
    }
1288
1289
    /**
1290 1
     * Returns the current price of the event respecting possible price options
1291
     *
1292
     * @return float
1293
     */
1294
    public function getCurrentPrice()
1295
    {
1296
        $activePriceOptions = $this->getActivePriceOptions();
1297
        if (count($activePriceOptions) >= 1) {
1298
            // Sort active price options and return first element
1299 1
            return reset($activePriceOptions)->getPrice();
1300
        } else {
1301 1
            // Just return the price field
1302
            return $this->price;
1303
        }
1304
    }
1305
1306
    /**
1307
     * Returns registrationWaitlist
1308
     *
1309
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
1310
     */
1311 3
    public function getRegistrationWaitlist()
1312
    {
1313 3
        return $this->registrationWaitlist;
1314 3
    }
1315
1316
    /**
1317
     * Sets registrationWaitlist
1318
     *
1319
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $registration Registration
1320
     *
1321
     * @return void
1322
     */
1323 1
    public function setRegistrationWaitlist(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $registration)
1324
    {
1325 1
        $this->registrationWaitlist = $registration;
1326 1
    }
1327
1328
    /**
1329
     * Adds a Registration to the waitlist
1330
     *
1331
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration Registration
1332
     *
1333
     * @return void
1334
     */
1335 1
    public function addRegistrationWaitlist(\DERHANSEN\SfEventMgt\Domain\Model\Registration $registration)
1336
    {
1337 1
        $this->registrationWaitlist->attach($registration);
1338 1
    }
1339
1340
    /**
1341
     * Removes a Registration from the waitlist
1342
     *
1343
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registrationToRemove Registration
1344
     *
1345 3
     * @return void
1346
     */
1347 3
    public function removeRegistrationWaitlist(\DERHANSEN\SfEventMgt\Domain\Model\Registration $registrationToRemove)
1348
    {
1349
        $this->registrationWaitlist->detach($registrationToRemove);
1350
    }
1351
1352
    /**
1353
     * Returns, if cancellation for registrations of the event is possible
1354
     *
1355
     * @return bool
1356
     */
1357
    public function getCancellationPossible()
1358
    {
1359
        return $this->getEnableCancel() && $this->getCancelDeadline() > new \DateTime();
1360
    }
1361
1362
    /**
1363
     * Returns speaker
1364
     *
1365
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
1366
     */
1367
    public function getSpeaker()
1368
    {
1369
        return $this->speaker;
1370
    }
1371
1372
    /**
1373
     * Sets speaker
1374
     *
1375
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $speaker
1376
     * @return void
1377
     */
1378
    public function setSpeaker($speaker)
1379
    {
1380
        $this->speaker = $speaker;
1381
    }
1382
1383
    /**
1384
     * Adds a speaker
1385
     *
1386
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Speaker $speaker
1387
     *
1388
     * @return void
1389
     */
1390
    public function addSpeaker(\DERHANSEN\SfEventMgt\Domain\Model\Speaker $speaker)
1391
    {
1392
        $this->speaker->attach($speaker);
1393
    }
1394
1395
    /**
1396
     * Removes a speaker
1397
     *
1398
     * @param \DERHANSEN\SfEventMgt\Domain\Model\Speaker $speaker
1399
     *
1400
     * @return void
1401
     */
1402
    public function removeSpeaker(\DERHANSEN\SfEventMgt\Domain\Model\Speaker $speaker)
1403
    {
1404
        $this->speaker->detach($speaker);
1405
    }
1406
1407
    /**
1408
     * Returns registrationFields
1409
     *
1410
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
1411
     */
1412
    public function getRegistrationFields()
1413
    {
1414
        return $this->registrationFields;
1415
    }
1416
1417
    /**
1418
     * Sets registrationWaitlist
1419
     *
1420
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $registrationFields
1421
     *
1422
     * @return void
1423
     */
1424
    public function setRegistrationFields(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $registrationFields)
1425
    {
1426
        $this->registrationFields = $registrationFields;
1427
    }
1428
1429
    /**
1430
     * Adds a registrationField
1431
     *
1432
     * @param Field $registrationField
1433
     */
1434
    public function addRegistrationFields(Field $registrationField)
1435
    {
1436
        $this->registrationFields->attach($registrationField);
1437
    }
1438
1439
    /**
1440
     * Removed a registrationField
1441
     *
1442
     * @param Field $registrationField
1443
     */
1444
    public function removeRegistrationFields(Field $registrationField)
1445
    {
1446
        $this->registrationFields->detach($registrationField);
1447
    }
1448
1449
    /**
1450
     * Returns an array with registration fields
1451
     *
1452
     * @return array
1453
     */
1454
    public function getRegistrationFieldsUids()
1455
    {
1456
        $result = [];
1457
        foreach ($this->registrationFields as $registrationField) {
1458
            $result[] = $registrationField->getUid();
1459
        }
1460
        return $result;
1461
    }
1462
}
1463