Completed
Push — development ( b2c13c...294738 )
by Torben
09:28
created

Event::setTitle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

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