Completed
Push — development ( 2615d6...2e5711 )
by Torben
08:07
created

Event::setTitle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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