Completed
Push — development ( ec29fe...c7aaa2 )
by Torben
43:55
created

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