Total Complexity | 168 |
Total Lines | 1711 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
Complex classes like Event often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Event, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
27 | class Event extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity |
||
28 | { |
||
29 | /** |
||
30 | * @var \DateTime |
||
31 | */ |
||
32 | protected $tstamp; |
||
33 | |||
34 | /** |
||
35 | * @var bool |
||
36 | */ |
||
37 | protected $hidden = false; |
||
38 | |||
39 | /** |
||
40 | * @var \DateTime |
||
41 | */ |
||
42 | protected $starttime; |
||
43 | |||
44 | /** |
||
45 | * @var \DateTime |
||
46 | */ |
||
47 | protected $endtime; |
||
48 | |||
49 | /** |
||
50 | * Title |
||
51 | * |
||
52 | * @var string |
||
53 | */ |
||
54 | protected $title = ''; |
||
55 | |||
56 | /** |
||
57 | * Teaser |
||
58 | * |
||
59 | * @var string |
||
60 | */ |
||
61 | protected $teaser = ''; |
||
62 | |||
63 | /** |
||
64 | * Description |
||
65 | * |
||
66 | * @var string |
||
67 | */ |
||
68 | protected $description = ''; |
||
69 | |||
70 | /** |
||
71 | * Program/Schedule |
||
72 | * |
||
73 | * @var string |
||
74 | */ |
||
75 | protected $program = ''; |
||
76 | |||
77 | /** |
||
78 | * Custom Text |
||
79 | * |
||
80 | * @var string |
||
81 | */ |
||
82 | protected $customText = ''; |
||
83 | |||
84 | /** |
||
85 | * Startdate and time |
||
86 | * |
||
87 | * @var \DateTime |
||
88 | */ |
||
89 | protected $startdate; |
||
90 | |||
91 | /** |
||
92 | * Enddate and time |
||
93 | * |
||
94 | * @var \DateTime |
||
95 | */ |
||
96 | protected $enddate; |
||
97 | |||
98 | /** |
||
99 | * Max participants |
||
100 | * |
||
101 | * @var int |
||
102 | */ |
||
103 | protected $maxParticipants = 0; |
||
104 | |||
105 | /** |
||
106 | * Max registrations per user |
||
107 | * |
||
108 | * @var int |
||
109 | */ |
||
110 | protected $maxRegistrationsPerUser = 1; |
||
111 | |||
112 | /** |
||
113 | * Price |
||
114 | * |
||
115 | * @var float |
||
116 | */ |
||
117 | protected $price = 0.0; |
||
118 | |||
119 | /** |
||
120 | * Currency |
||
121 | * |
||
122 | * @var string |
||
123 | */ |
||
124 | protected $currency = ''; |
||
125 | |||
126 | /** |
||
127 | * Enable payment |
||
128 | * |
||
129 | * @var bool |
||
130 | */ |
||
131 | protected $enablePayment = false; |
||
132 | |||
133 | /** |
||
134 | * Restrict payment methods |
||
135 | * |
||
136 | * @var bool |
||
137 | */ |
||
138 | protected $restrictPaymentMethods = false; |
||
139 | |||
140 | /** |
||
141 | * Selected payment methods |
||
142 | * |
||
143 | * @var string |
||
144 | */ |
||
145 | protected $selectedPaymentMethods = ''; |
||
146 | |||
147 | /** |
||
148 | * Category |
||
149 | * |
||
150 | * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\DERHANSEN\SfEventMgt\Domain\Model\Category> |
||
151 | * @Extbase\ORM\Lazy |
||
152 | */ |
||
153 | protected $category; |
||
154 | |||
155 | /** |
||
156 | * Related |
||
157 | * |
||
158 | * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\DERHANSEN\SfEventMgt\Domain\Model\Event> |
||
159 | * @Extbase\ORM\Lazy |
||
160 | */ |
||
161 | protected $related; |
||
162 | |||
163 | /** |
||
164 | * Registration |
||
165 | * |
||
166 | * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\DERHANSEN\SfEventMgt\Domain\Model\Registration> |
||
167 | * @Extbase\ORM\Cascade("remove") |
||
168 | * @Extbase\ORM\Lazy |
||
169 | */ |
||
170 | protected $registration; |
||
171 | |||
172 | /** |
||
173 | * Registration waitlist |
||
174 | * |
||
175 | * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\DERHANSEN\SfEventMgt\Domain\Model\Registration> |
||
176 | * @Extbase\ORM\Lazy |
||
177 | */ |
||
178 | protected $registrationWaitlist; |
||
179 | |||
180 | /** |
||
181 | * Registration fields |
||
182 | * |
||
183 | * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\DERHANSEN\SfEventMgt\Domain\Model\Registration\Field> |
||
184 | * @Extbase\ORM\Lazy |
||
185 | */ |
||
186 | protected $registrationFields; |
||
187 | |||
188 | /** |
||
189 | * Registration start date |
||
190 | * |
||
191 | * @var \DateTime |
||
192 | */ |
||
193 | protected $registrationStartdate; |
||
194 | |||
195 | /** |
||
196 | * Registration deadline date |
||
197 | * |
||
198 | * @var \DateTime |
||
199 | */ |
||
200 | protected $registrationDeadline; |
||
201 | |||
202 | /** |
||
203 | * The image |
||
204 | * |
||
205 | * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> |
||
206 | * @Extbase\ORM\Lazy |
||
207 | */ |
||
208 | protected $image; |
||
209 | |||
210 | /** |
||
211 | * Additional files |
||
212 | * |
||
213 | * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> |
||
214 | * @Extbase\ORM\Lazy |
||
215 | */ |
||
216 | protected $files; |
||
217 | |||
218 | /** |
||
219 | * The Location |
||
220 | * |
||
221 | * @var \DERHANSEN\SfEventMgt\Domain\Model\Location |
||
222 | */ |
||
223 | protected $location; |
||
224 | |||
225 | /** |
||
226 | * Room |
||
227 | * |
||
228 | * @var string |
||
229 | */ |
||
230 | protected $room; |
||
231 | |||
232 | /** |
||
233 | * Enable registration |
||
234 | * |
||
235 | * @var bool |
||
236 | */ |
||
237 | protected $enableRegistration = false; |
||
238 | |||
239 | /** |
||
240 | * Enable waitlist |
||
241 | * |
||
242 | * @var bool |
||
243 | */ |
||
244 | protected $enableWaitlist = false; |
||
245 | |||
246 | /** |
||
247 | * Enable waitlist |
||
248 | * |
||
249 | * @var bool |
||
250 | */ |
||
251 | protected $enableWaitlistMoveup = false; |
||
252 | |||
253 | /** |
||
254 | * Link |
||
255 | * |
||
256 | * @var string |
||
257 | */ |
||
258 | protected $link; |
||
259 | |||
260 | /** |
||
261 | * Top event |
||
262 | * |
||
263 | * @var bool |
||
264 | */ |
||
265 | protected $topEvent = false; |
||
266 | |||
267 | /** |
||
268 | * The additionalImage |
||
269 | * |
||
270 | * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> |
||
271 | * @Extbase\ORM\Lazy |
||
272 | */ |
||
273 | protected $additionalImage; |
||
274 | |||
275 | /** |
||
276 | * The organisator |
||
277 | * |
||
278 | * @var \DERHANSEN\SfEventMgt\Domain\Model\Organisator |
||
279 | */ |
||
280 | protected $organisator; |
||
281 | |||
282 | /** |
||
283 | * Notify admin |
||
284 | * |
||
285 | * @var bool |
||
286 | */ |
||
287 | protected $notifyAdmin = true; |
||
288 | |||
289 | /** |
||
290 | * Notify organisator |
||
291 | * |
||
292 | * @var bool |
||
293 | */ |
||
294 | protected $notifyOrganisator = false; |
||
295 | |||
296 | /** |
||
297 | * Enable cancel of registration |
||
298 | * |
||
299 | * @var bool |
||
300 | */ |
||
301 | protected $enableCancel = false; |
||
302 | |||
303 | /** |
||
304 | * Deadline for cancel |
||
305 | * |
||
306 | * @var \DateTime |
||
307 | */ |
||
308 | protected $cancelDeadline; |
||
309 | |||
310 | /** |
||
311 | * Enable auto confirmation |
||
312 | * |
||
313 | * @var bool |
||
314 | */ |
||
315 | protected $enableAutoconfirm = false; |
||
316 | |||
317 | /** |
||
318 | * Unique email check |
||
319 | * |
||
320 | * @var bool |
||
321 | */ |
||
322 | protected $uniqueEmailCheck = false; |
||
323 | |||
324 | /** |
||
325 | * Price options |
||
326 | * |
||
327 | * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\DERHANSEN\SfEventMgt\Domain\Model\PriceOption> |
||
328 | * @Extbase\ORM\Cascade("remove") |
||
329 | * @Extbase\ORM\Lazy |
||
330 | */ |
||
331 | protected $priceOptions; |
||
332 | |||
333 | /** |
||
334 | * Speaker |
||
335 | * |
||
336 | * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\DERHANSEN\SfEventMgt\Domain\Model\Speaker> |
||
337 | * @Extbase\ORM\Lazy |
||
338 | */ |
||
339 | protected $speaker; |
||
340 | |||
341 | /** |
||
342 | * Constructor |
||
343 | */ |
||
344 | public function __construct() |
||
345 | { |
||
346 | $this->category = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); |
||
347 | $this->related = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); |
||
348 | $this->registration = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); |
||
349 | $this->registrationWaitlist = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); |
||
350 | $this->registrationFields = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); |
||
351 | $this->image = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); |
||
352 | $this->files = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); |
||
353 | $this->additionalImage = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); |
||
354 | $this->priceOptions = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); |
||
355 | $this->speaker = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); |
||
356 | } |
||
357 | |||
358 | /** |
||
359 | * Get timestamp |
||
360 | * |
||
361 | * @return \DateTime |
||
362 | */ |
||
363 | public function getTstamp() |
||
364 | { |
||
365 | return $this->tstamp; |
||
366 | } |
||
367 | |||
368 | /** |
||
369 | * Set time stamp |
||
370 | * |
||
371 | * @param \DateTime $tstamp time stamp |
||
372 | */ |
||
373 | public function setTstamp($tstamp) |
||
374 | { |
||
375 | $this->tstamp = $tstamp; |
||
376 | } |
||
377 | |||
378 | /** |
||
379 | * Get hidden flag |
||
380 | * |
||
381 | * @return bool |
||
382 | */ |
||
383 | public function getHidden() |
||
384 | { |
||
385 | return $this->hidden; |
||
386 | } |
||
387 | |||
388 | /** |
||
389 | * Set hidden flag |
||
390 | * |
||
391 | * @param bool $hidden hidden flag |
||
392 | */ |
||
393 | public function setHidden($hidden) |
||
394 | { |
||
395 | $this->hidden = $hidden; |
||
396 | } |
||
397 | |||
398 | /** |
||
399 | * Get start time |
||
400 | * |
||
401 | * @return \DateTime |
||
402 | */ |
||
403 | public function getStarttime() |
||
404 | { |
||
405 | return $this->starttime; |
||
406 | } |
||
407 | |||
408 | /** |
||
409 | * Set start time |
||
410 | * |
||
411 | * @param \DateTime $starttime start time |
||
412 | */ |
||
413 | public function setStarttime($starttime) |
||
414 | { |
||
415 | $this->starttime = $starttime; |
||
416 | } |
||
417 | |||
418 | /** |
||
419 | * Get endtime |
||
420 | * |
||
421 | * @return \DateTime |
||
422 | */ |
||
423 | public function getEndtime() |
||
424 | { |
||
425 | return $this->endtime; |
||
426 | } |
||
427 | |||
428 | /** |
||
429 | * Set end time |
||
430 | * |
||
431 | * @param \DateTime $endtime end time |
||
432 | */ |
||
433 | public function setEndtime($endtime) |
||
434 | { |
||
435 | $this->endtime = $endtime; |
||
436 | } |
||
437 | |||
438 | /** |
||
439 | * Returns the title |
||
440 | * |
||
441 | * @return string $title |
||
442 | */ |
||
443 | public function getTitle() |
||
444 | { |
||
445 | return $this->title; |
||
446 | } |
||
447 | |||
448 | /** |
||
449 | * Sets the title |
||
450 | * |
||
451 | * @param string $title Title |
||
452 | */ |
||
453 | public function setTitle($title) |
||
454 | { |
||
455 | $this->title = $title; |
||
456 | } |
||
457 | |||
458 | /** |
||
459 | * Returns the teaser |
||
460 | * |
||
461 | * @return string |
||
462 | */ |
||
463 | public function getTeaser() |
||
464 | { |
||
465 | return $this->teaser; |
||
466 | } |
||
467 | |||
468 | /** |
||
469 | * Sets the teaser |
||
470 | * |
||
471 | * @param string $teaser Teaser |
||
472 | */ |
||
473 | public function setTeaser($teaser) |
||
474 | { |
||
475 | $this->teaser = $teaser; |
||
476 | } |
||
477 | |||
478 | /** |
||
479 | * Returns the description |
||
480 | * |
||
481 | * @return string $description |
||
482 | */ |
||
483 | public function getDescription() |
||
484 | { |
||
485 | return $this->description; |
||
486 | } |
||
487 | |||
488 | /** |
||
489 | * Sets the description |
||
490 | * |
||
491 | * @param string $description Description |
||
492 | */ |
||
493 | public function setDescription($description) |
||
494 | { |
||
495 | $this->description = $description; |
||
496 | } |
||
497 | |||
498 | /** |
||
499 | * Returns the program |
||
500 | * |
||
501 | * @return string $program |
||
502 | */ |
||
503 | public function getProgram() |
||
504 | { |
||
505 | return $this->program; |
||
506 | } |
||
507 | |||
508 | /** |
||
509 | * Sets the program |
||
510 | * |
||
511 | * @param string $program The program |
||
512 | */ |
||
513 | public function setProgram($program) |
||
514 | { |
||
515 | $this->program = $program; |
||
516 | } |
||
517 | |||
518 | /** |
||
519 | * @return string |
||
520 | */ |
||
521 | public function getCustomText() |
||
522 | { |
||
523 | return $this->customText; |
||
524 | } |
||
525 | |||
526 | /** |
||
527 | * @param string $customText |
||
528 | */ |
||
529 | public function setCustomText($customText) |
||
530 | { |
||
531 | $this->customText = $customText; |
||
532 | } |
||
533 | |||
534 | /** |
||
535 | * Returns the startdate |
||
536 | * |
||
537 | * @return \DateTime $startdate |
||
538 | */ |
||
539 | public function getStartdate() |
||
540 | { |
||
541 | return $this->startdate; |
||
542 | } |
||
543 | |||
544 | /** |
||
545 | * Sets the startdate |
||
546 | * |
||
547 | * @param \DateTime $startdate Startdate |
||
548 | */ |
||
549 | public function setStartdate(\DateTime $startdate) |
||
550 | { |
||
551 | $this->startdate = $startdate; |
||
552 | } |
||
553 | |||
554 | /** |
||
555 | * Returns the enddate |
||
556 | * |
||
557 | * @return \DateTime $enddate |
||
558 | */ |
||
559 | public function getEnddate() |
||
560 | { |
||
561 | return $this->enddate; |
||
562 | } |
||
563 | |||
564 | /** |
||
565 | * Sets the enddate |
||
566 | * |
||
567 | * @param \DateTime $enddate Enddate |
||
568 | */ |
||
569 | public function setEnddate(\DateTime $enddate) |
||
570 | { |
||
571 | $this->enddate = $enddate; |
||
572 | } |
||
573 | |||
574 | /** |
||
575 | * Returns the participants |
||
576 | * |
||
577 | * @return int $participants |
||
578 | */ |
||
579 | public function getMaxParticipants() |
||
580 | { |
||
581 | return $this->maxParticipants; |
||
582 | } |
||
583 | |||
584 | /** |
||
585 | * Sets the participants |
||
586 | * |
||
587 | * @param int $participants Participants |
||
588 | */ |
||
589 | public function setMaxParticipants($participants) |
||
590 | { |
||
591 | $this->maxParticipants = $participants; |
||
592 | } |
||
593 | |||
594 | /** |
||
595 | * Returns the price |
||
596 | * |
||
597 | * @return float $price |
||
598 | */ |
||
599 | public function getPrice() |
||
600 | { |
||
601 | return $this->price; |
||
602 | } |
||
603 | |||
604 | /** |
||
605 | * Sets the price |
||
606 | * |
||
607 | * @param float $price Price |
||
608 | */ |
||
609 | public function setPrice($price) |
||
610 | { |
||
611 | $this->price = $price; |
||
612 | } |
||
613 | |||
614 | /** |
||
615 | * Returns the currency |
||
616 | * |
||
617 | * @return string $currency |
||
618 | */ |
||
619 | public function getCurrency() |
||
620 | { |
||
621 | return $this->currency; |
||
622 | } |
||
623 | |||
624 | /** |
||
625 | * Sets the currency |
||
626 | * |
||
627 | * @param string $currency Currency |
||
628 | */ |
||
629 | public function setCurrency($currency) |
||
630 | { |
||
631 | $this->currency = $currency; |
||
632 | } |
||
633 | |||
634 | /** |
||
635 | * Returns if payment is enabled |
||
636 | * |
||
637 | * @return bool |
||
638 | */ |
||
639 | public function getEnablePayment() |
||
640 | { |
||
641 | return $this->enablePayment; |
||
642 | } |
||
643 | |||
644 | /** |
||
645 | * Sets enablePayment |
||
646 | * |
||
647 | * @param bool $enablePayment |
||
648 | */ |
||
649 | public function setEnablePayment($enablePayment) |
||
650 | { |
||
651 | $this->enablePayment = $enablePayment; |
||
652 | } |
||
653 | |||
654 | /** |
||
655 | * Returns if payment methods should be restricted |
||
656 | * |
||
657 | * @return bool |
||
658 | */ |
||
659 | public function getRestrictPaymentMethods() |
||
660 | { |
||
661 | return $this->restrictPaymentMethods; |
||
662 | } |
||
663 | |||
664 | /** |
||
665 | * Sets if payment methods should be restricted |
||
666 | * |
||
667 | * @param bool $restrictPaymentMethods |
||
668 | */ |
||
669 | public function setRestrictPaymentMethods($restrictPaymentMethods) |
||
670 | { |
||
671 | $this->restrictPaymentMethods = $restrictPaymentMethods; |
||
672 | } |
||
673 | |||
674 | /** |
||
675 | * Returns selected payment methods |
||
676 | * |
||
677 | * @return string |
||
678 | */ |
||
679 | public function getSelectedPaymentMethods() |
||
680 | { |
||
681 | return $this->selectedPaymentMethods; |
||
682 | } |
||
683 | |||
684 | /** |
||
685 | * Sets selected payment methods |
||
686 | * |
||
687 | * @param string $selectedPaymentMethods |
||
688 | */ |
||
689 | public function setSelectedPaymentMethods($selectedPaymentMethods) |
||
690 | { |
||
691 | $this->selectedPaymentMethods = $selectedPaymentMethods; |
||
692 | } |
||
693 | |||
694 | /** |
||
695 | * Adds a Category |
||
696 | * |
||
697 | * @param \DERHANSEN\SfEventMgt\Domain\Model\Category $category Category |
||
698 | */ |
||
699 | public function addCategory(\DERHANSEN\SfEventMgt\Domain\Model\Category $category) |
||
700 | { |
||
701 | $this->category->attach($category); |
||
702 | } |
||
703 | |||
704 | /** |
||
705 | * Removes a Category |
||
706 | * |
||
707 | * @param \DERHANSEN\SfEventMgt\Domain\Model\Category $categoryToRemove The Category to be removed |
||
708 | */ |
||
709 | public function removeCategory(\DERHANSEN\SfEventMgt\Domain\Model\Category $categoryToRemove) |
||
710 | { |
||
711 | $this->category->detach($categoryToRemove); |
||
712 | } |
||
713 | |||
714 | /** |
||
715 | * Returns the category |
||
716 | * |
||
717 | * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage |
||
718 | */ |
||
719 | public function getCategory() |
||
720 | { |
||
721 | return $this->category; |
||
722 | } |
||
723 | |||
724 | /** |
||
725 | * Returns the category |
||
726 | * |
||
727 | * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage |
||
728 | */ |
||
729 | public function getCategories() |
||
730 | { |
||
731 | return $this->category; |
||
732 | } |
||
733 | |||
734 | /** |
||
735 | * Sets the category |
||
736 | * |
||
737 | * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $category Category |
||
738 | */ |
||
739 | public function setCategory(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $category) |
||
740 | { |
||
741 | $this->category = $category; |
||
742 | } |
||
743 | |||
744 | /** |
||
745 | * Returns related events |
||
746 | * |
||
747 | * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage |
||
748 | */ |
||
749 | public function getRelated() |
||
750 | { |
||
751 | return $this->related; |
||
752 | } |
||
753 | |||
754 | /** |
||
755 | * Sets related events |
||
756 | * |
||
757 | * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $related |
||
758 | */ |
||
759 | public function setRelated($related) |
||
760 | { |
||
761 | $this->related = $related; |
||
762 | } |
||
763 | |||
764 | /** |
||
765 | * Adds a related event |
||
766 | * |
||
767 | * @param Event $event |
||
768 | */ |
||
769 | public function addRelated(\DERHANSEN\SfEventMgt\Domain\Model\Event $event) |
||
770 | { |
||
771 | $this->related->attach($event); |
||
772 | } |
||
773 | |||
774 | /** |
||
775 | * Removes a related event |
||
776 | * |
||
777 | * @param Event $event |
||
778 | */ |
||
779 | public function removeRelated(\DERHANSEN\SfEventMgt\Domain\Model\Event $event) |
||
780 | { |
||
781 | $this->related->detach($event); |
||
782 | } |
||
783 | |||
784 | /** |
||
785 | * Adds a Registration |
||
786 | * |
||
787 | * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration Registration |
||
788 | */ |
||
789 | public function addRegistration(\DERHANSEN\SfEventMgt\Domain\Model\Registration $registration) |
||
790 | { |
||
791 | $this->registration->attach($registration); |
||
792 | } |
||
793 | |||
794 | /** |
||
795 | * Removes a Registration |
||
796 | * |
||
797 | * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registrationToRemove Registration |
||
798 | */ |
||
799 | public function removeRegistration(\DERHANSEN\SfEventMgt\Domain\Model\Registration $registrationToRemove) |
||
800 | { |
||
801 | $this->registration->detach($registrationToRemove); |
||
802 | } |
||
803 | |||
804 | /** |
||
805 | * Returns the Registration |
||
806 | * |
||
807 | * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $registration |
||
808 | */ |
||
809 | public function getRegistration() |
||
810 | { |
||
811 | return $this->registration; |
||
812 | } |
||
813 | |||
814 | /** |
||
815 | * Sets the Registration |
||
816 | * |
||
817 | * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $registration Registration |
||
818 | */ |
||
819 | public function setRegistration(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $registration) |
||
820 | { |
||
821 | $this->registration = $registration; |
||
822 | } |
||
823 | |||
824 | /** |
||
825 | * Adds an image |
||
826 | * |
||
827 | * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $image Image |
||
828 | */ |
||
829 | public function addImage(\TYPO3\CMS\Extbase\Domain\Model\FileReference $image) |
||
830 | { |
||
831 | $this->image->attach($image); |
||
832 | } |
||
833 | |||
834 | /** |
||
835 | * Removes an image |
||
836 | * |
||
837 | * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $imageToRemove Image |
||
838 | */ |
||
839 | public function removeImage(\TYPO3\CMS\Extbase\Domain\Model\FileReference $imageToRemove) |
||
840 | { |
||
841 | $this->image->detach($imageToRemove); |
||
842 | } |
||
843 | |||
844 | /** |
||
845 | * Returns all items of the field image |
||
846 | * |
||
847 | * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> $image |
||
848 | */ |
||
849 | public function getImage() |
||
850 | { |
||
851 | return $this->image; |
||
852 | } |
||
853 | |||
854 | /** |
||
855 | * Special getter to return images when accesses as {event.images} |
||
856 | * |
||
857 | * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> |
||
858 | */ |
||
859 | public function getImages() |
||
860 | { |
||
861 | return $this->image; |
||
862 | } |
||
863 | |||
864 | /** |
||
865 | * Returns all image items configured for list view |
||
866 | * |
||
867 | * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> |
||
868 | */ |
||
869 | public function getListViewImages() |
||
870 | { |
||
871 | return $this->getImagesByType(ShowInPreviews::LIST_VIEWS); |
||
872 | } |
||
873 | |||
874 | /** |
||
875 | * Returns the first list view image as file reference object |
||
876 | * |
||
877 | * @return \TYPO3\CMS\Extbase\Domain\Model\FileReference|null |
||
878 | */ |
||
879 | public function getFirstListViewImage() |
||
880 | { |
||
881 | $images = $this->getImagesByType(ShowInPreviews::LIST_VIEWS); |
||
882 | $image = $images->current(); |
||
883 | |||
884 | if (is_a($image, \TYPO3\CMS\Extbase\Domain\Model\FileReference::class)) { |
||
885 | return $image; |
||
886 | } else { |
||
887 | return null; |
||
888 | } |
||
889 | } |
||
890 | |||
891 | /** |
||
892 | * Returns all image items configured for list view |
||
893 | * |
||
894 | * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> |
||
895 | */ |
||
896 | public function getDetailViewImages() |
||
897 | { |
||
898 | return $this->getImagesByType(ShowInPreviews::DETAIL_VIEWS); |
||
899 | } |
||
900 | |||
901 | /** |
||
902 | * Returns the first detail view image as file reference object |
||
903 | * |
||
904 | * @return \TYPO3\CMS\Extbase\Domain\Model\FileReference|null |
||
905 | */ |
||
906 | public function getFirstDetailViewImage() |
||
907 | { |
||
908 | $images = $this->getImagesByType(ShowInPreviews::DETAIL_VIEWS); |
||
909 | $image = $images->current(); |
||
910 | |||
911 | if (is_a($image, \TYPO3\CMS\Extbase\Domain\Model\FileReference::class)) { |
||
912 | return $image; |
||
913 | } else { |
||
914 | return null; |
||
915 | } |
||
916 | } |
||
917 | |||
918 | /** |
||
919 | * Returns all image items by the given type |
||
920 | * |
||
921 | * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> |
||
922 | */ |
||
923 | protected function getImagesByType(int $type) |
||
924 | { |
||
925 | $result = new ObjectStorage(); |
||
926 | |||
927 | foreach ($this->image as $image) { |
||
928 | /** @var FileReference $fileReference */ |
||
929 | $fileReference = $image->getOriginalResource(); |
||
|
|||
930 | if ($fileReference && $fileReference->hasProperty('show_in_views') && |
||
931 | in_array($fileReference->getProperty('show_in_views'), [$type, ShowInPreviews::ALL_VIEWS]) |
||
932 | ) { |
||
933 | $result->attach($image); |
||
934 | } |
||
935 | } |
||
936 | |||
937 | return $result; |
||
938 | } |
||
939 | |||
940 | /** |
||
941 | * Sets the image |
||
942 | * |
||
943 | * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\TYPO3\CMS\Extbase\Domain\Model\FileReference> $image Image |
||
944 | */ |
||
945 | public function setImage(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $image) |
||
946 | { |
||
947 | $this->image = $image; |
||
948 | } |
||
949 | |||
950 | /** |
||
951 | * Adds a file |
||
952 | * |
||
953 | * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $file File |
||
954 | */ |
||
955 | public function addFiles(\TYPO3\CMS\Extbase\Domain\Model\FileReference $file) |
||
956 | { |
||
957 | $this->files->attach($file); |
||
958 | } |
||
959 | |||
960 | /** |
||
961 | * Removes a file |
||
962 | * |
||
963 | * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $fileToRemove File |
||
964 | */ |
||
965 | public function removeFiles(\TYPO3\CMS\Extbase\Domain\Model\FileReference $fileToRemove) |
||
966 | { |
||
967 | $this->files->detach($fileToRemove); |
||
968 | } |
||
969 | |||
970 | /** |
||
971 | * Returns the files |
||
972 | * |
||
973 | * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $files |
||
974 | */ |
||
975 | public function getFiles() |
||
976 | { |
||
977 | return $this->files; |
||
978 | } |
||
979 | |||
980 | /** |
||
981 | * Sets the files |
||
982 | * |
||
983 | * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $files Files |
||
984 | */ |
||
985 | public function setFiles(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $files) |
||
986 | { |
||
987 | $this->files = $files; |
||
988 | } |
||
989 | |||
990 | /** |
||
991 | * Returns if the registration for this event is logically possible |
||
992 | * |
||
993 | * @return bool |
||
994 | */ |
||
995 | public function getRegistrationPossible() |
||
1013 | } |
||
1014 | |||
1015 | /** |
||
1016 | * Returns the amount of free places |
||
1017 | * |
||
1018 | * @return int |
||
1019 | */ |
||
1020 | public function getFreePlaces() |
||
1021 | { |
||
1022 | return $this->maxParticipants - $this->getRegistrations()->count(); |
||
1023 | } |
||
1024 | |||
1025 | /** |
||
1026 | * Sets the location |
||
1027 | * |
||
1028 | * @param \DERHANSEN\SfEventMgt\Domain\Model\Location $location Location |
||
1029 | */ |
||
1030 | public function setLocation($location) |
||
1031 | { |
||
1032 | $this->location = $location; |
||
1033 | } |
||
1034 | |||
1035 | /** |
||
1036 | * Returns the location |
||
1037 | * |
||
1038 | * @return \DERHANSEN\SfEventMgt\Domain\Model\Location |
||
1039 | */ |
||
1040 | public function getLocation() |
||
1041 | { |
||
1042 | return $this->location; |
||
1043 | } |
||
1044 | |||
1045 | /** |
||
1046 | * Returns the room |
||
1047 | * |
||
1048 | * @return string |
||
1049 | */ |
||
1050 | public function getRoom() |
||
1051 | { |
||
1052 | return $this->room; |
||
1053 | } |
||
1054 | |||
1055 | /** |
||
1056 | * Sets the room |
||
1057 | * |
||
1058 | * @param string $room |
||
1059 | */ |
||
1060 | public function setRoom($room) |
||
1061 | { |
||
1062 | $this->room = $room; |
||
1063 | } |
||
1064 | |||
1065 | /** |
||
1066 | * Sets enableRegistration |
||
1067 | * |
||
1068 | * @param bool $enableRegistration EnableRegistration |
||
1069 | */ |
||
1070 | public function setEnableRegistration($enableRegistration) |
||
1071 | { |
||
1072 | $this->enableRegistration = $enableRegistration; |
||
1073 | } |
||
1074 | |||
1075 | /** |
||
1076 | * Returns if registration is enabled |
||
1077 | * |
||
1078 | * @return bool |
||
1079 | */ |
||
1080 | public function getEnableRegistration() |
||
1081 | { |
||
1082 | return $this->enableRegistration; |
||
1083 | } |
||
1084 | |||
1085 | /** |
||
1086 | * Returns enableWaitlist |
||
1087 | * |
||
1088 | * @return bool |
||
1089 | */ |
||
1090 | public function getEnableWaitlist() |
||
1091 | { |
||
1092 | return $this->enableWaitlist; |
||
1093 | } |
||
1094 | |||
1095 | /** |
||
1096 | * Sets enableWaitlist |
||
1097 | * |
||
1098 | * @param bool $enableWaitlist |
||
1099 | */ |
||
1100 | public function setEnableWaitlist($enableWaitlist) |
||
1101 | { |
||
1102 | $this->enableWaitlist = $enableWaitlist; |
||
1103 | } |
||
1104 | |||
1105 | /** |
||
1106 | * @return bool |
||
1107 | */ |
||
1108 | public function getEnableWaitlistMoveup(): bool |
||
1109 | { |
||
1110 | return $this->enableWaitlistMoveup; |
||
1111 | } |
||
1112 | |||
1113 | /** |
||
1114 | * @param bool $enableWaitlistMoveup |
||
1115 | */ |
||
1116 | public function setEnableWaitlistMoveup($enableWaitlistMoveup): void |
||
1117 | { |
||
1118 | $this->enableWaitlistMoveup = $enableWaitlistMoveup; |
||
1119 | } |
||
1120 | |||
1121 | /** |
||
1122 | * Sets the registration startdate |
||
1123 | * |
||
1124 | * @param \DateTime $registrationStartdate RegistrationStartdate |
||
1125 | */ |
||
1126 | public function setRegistrationStartdate(\DateTime $registrationStartdate) |
||
1127 | { |
||
1128 | $this->registrationStartdate = $registrationStartdate; |
||
1129 | } |
||
1130 | |||
1131 | /** |
||
1132 | * Returns the registration startdate |
||
1133 | * |
||
1134 | * @return \DateTime |
||
1135 | */ |
||
1136 | public function getRegistrationStartdate() |
||
1137 | { |
||
1138 | return $this->registrationStartdate; |
||
1139 | } |
||
1140 | |||
1141 | /** |
||
1142 | * Sets the registration deadline |
||
1143 | * |
||
1144 | * @param \DateTime $registrationDeadline RegistrationDeadline |
||
1145 | */ |
||
1146 | public function setRegistrationDeadline(\DateTime $registrationDeadline) |
||
1147 | { |
||
1148 | $this->registrationDeadline = $registrationDeadline; |
||
1149 | } |
||
1150 | |||
1151 | /** |
||
1152 | * Returns the registration deadline |
||
1153 | * |
||
1154 | * @return \DateTime |
||
1155 | */ |
||
1156 | public function getRegistrationDeadline() |
||
1157 | { |
||
1158 | return $this->registrationDeadline; |
||
1159 | } |
||
1160 | |||
1161 | /** |
||
1162 | * Sets the link |
||
1163 | * |
||
1164 | * @param string $link Link |
||
1165 | */ |
||
1166 | public function setLink($link) |
||
1167 | { |
||
1168 | $this->link = $link; |
||
1169 | } |
||
1170 | |||
1171 | /** |
||
1172 | * Returns the link |
||
1173 | * |
||
1174 | * @return string |
||
1175 | */ |
||
1176 | public function getLink() |
||
1177 | { |
||
1178 | return $this->link; |
||
1179 | } |
||
1180 | |||
1181 | /** |
||
1182 | * Sets topEvent |
||
1183 | * |
||
1184 | * @param bool $topEvent TopEvent |
||
1185 | */ |
||
1186 | public function setTopEvent($topEvent) |
||
1187 | { |
||
1188 | $this->topEvent = $topEvent; |
||
1189 | } |
||
1190 | |||
1191 | /** |
||
1192 | * Returns if topEvent is checked |
||
1193 | * |
||
1194 | * @return bool |
||
1195 | */ |
||
1196 | public function getTopEvent() |
||
1197 | { |
||
1198 | return $this->topEvent; |
||
1199 | } |
||
1200 | |||
1201 | /** |
||
1202 | * Returns max regisrations per user |
||
1203 | * |
||
1204 | * @return int |
||
1205 | */ |
||
1206 | public function getMaxRegistrationsPerUser() |
||
1207 | { |
||
1208 | return $this->maxRegistrationsPerUser; |
||
1209 | } |
||
1210 | |||
1211 | /** |
||
1212 | * Sets max registrations per user |
||
1213 | * |
||
1214 | * @param int $maxRegistrationsPerUser MaxRegistrationsPerUser |
||
1215 | */ |
||
1216 | public function setMaxRegistrationsPerUser($maxRegistrationsPerUser) |
||
1217 | { |
||
1218 | $this->maxRegistrationsPerUser = $maxRegistrationsPerUser; |
||
1219 | } |
||
1220 | |||
1221 | /** |
||
1222 | * Adds an additionalImage |
||
1223 | * |
||
1224 | * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $additionalImage The Image |
||
1225 | */ |
||
1226 | public function addAdditionalImage(\TYPO3\CMS\Extbase\Domain\Model\FileReference $additionalImage) |
||
1227 | { |
||
1228 | $this->additionalImage->attach($additionalImage); |
||
1229 | } |
||
1230 | |||
1231 | /** |
||
1232 | * Removes an additionalImage |
||
1233 | * |
||
1234 | * @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $additionalImageToRemove The Image |
||
1235 | */ |
||
1236 | public function removeAdditionalImage(\TYPO3\CMS\Extbase\Domain\Model\FileReference $additionalImageToRemove) |
||
1237 | { |
||
1238 | $this->additionalImage->detach($additionalImageToRemove); |
||
1239 | } |
||
1240 | |||
1241 | /** |
||
1242 | * Returns the additionalImage |
||
1243 | * |
||
1244 | * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $additionalImage |
||
1245 | */ |
||
1246 | public function getAdditionalImage() |
||
1247 | { |
||
1248 | return $this->additionalImage; |
||
1249 | } |
||
1250 | |||
1251 | /** |
||
1252 | * Sets the additionalImage |
||
1253 | * |
||
1254 | * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $additionalImage The Image |
||
1255 | */ |
||
1256 | public function setAdditionalImage(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $additionalImage) |
||
1257 | { |
||
1258 | $this->additionalImage = $additionalImage; |
||
1259 | } |
||
1260 | |||
1261 | /** |
||
1262 | * Returns the organisator |
||
1263 | * |
||
1264 | * @return Organisator |
||
1265 | */ |
||
1266 | public function getOrganisator() |
||
1267 | { |
||
1268 | return $this->organisator; |
||
1269 | } |
||
1270 | |||
1271 | /** |
||
1272 | * Sets the organisator |
||
1273 | * |
||
1274 | * @param Organisator $organisator The organisator |
||
1275 | */ |
||
1276 | public function setOrganisator($organisator) |
||
1277 | { |
||
1278 | $this->organisator = $organisator; |
||
1279 | } |
||
1280 | |||
1281 | /** |
||
1282 | * Returns notifyAdmin |
||
1283 | * |
||
1284 | * @return bool |
||
1285 | */ |
||
1286 | public function getNotifyAdmin() |
||
1287 | { |
||
1288 | return $this->notifyAdmin; |
||
1289 | } |
||
1290 | |||
1291 | /** |
||
1292 | * Sets notifyAdmin |
||
1293 | * |
||
1294 | * @param bool $notifyAdmin NotifyAdmin |
||
1295 | */ |
||
1296 | public function setNotifyAdmin($notifyAdmin) |
||
1297 | { |
||
1298 | $this->notifyAdmin = $notifyAdmin; |
||
1299 | } |
||
1300 | |||
1301 | /** |
||
1302 | * Returns if notifyAdmin is set |
||
1303 | * |
||
1304 | * @return bool |
||
1305 | */ |
||
1306 | public function getNotifyOrganisator() |
||
1307 | { |
||
1308 | return $this->notifyOrganisator; |
||
1309 | } |
||
1310 | |||
1311 | /** |
||
1312 | * Sets notifyOrganisator |
||
1313 | * |
||
1314 | * @param bool $notifyOrganisator NotifyOrganisator |
||
1315 | */ |
||
1316 | public function setNotifyOrganisator($notifyOrganisator) |
||
1317 | { |
||
1318 | $this->notifyOrganisator = $notifyOrganisator; |
||
1319 | } |
||
1320 | |||
1321 | /** |
||
1322 | * Sets enableCancel |
||
1323 | * |
||
1324 | * @param bool $enableCancel EnableCancel |
||
1325 | */ |
||
1326 | public function setEnableCancel($enableCancel) |
||
1327 | { |
||
1328 | $this->enableCancel = $enableCancel; |
||
1329 | } |
||
1330 | |||
1331 | /** |
||
1332 | * Returns if registration can be canceled |
||
1333 | * |
||
1334 | * @return bool |
||
1335 | */ |
||
1336 | public function getEnableCancel() |
||
1337 | { |
||
1338 | return $this->enableCancel; |
||
1339 | } |
||
1340 | |||
1341 | /** |
||
1342 | * Sets the cancel deadline |
||
1343 | * |
||
1344 | * @param \DateTime $cancelDeadline CancelDeadline |
||
1345 | */ |
||
1346 | public function setCancelDeadline(\DateTime $cancelDeadline) |
||
1347 | { |
||
1348 | $this->cancelDeadline = $cancelDeadline; |
||
1349 | } |
||
1350 | |||
1351 | /** |
||
1352 | * Returns the cancel deadline |
||
1353 | * |
||
1354 | * @return \DateTime |
||
1355 | */ |
||
1356 | public function getCancelDeadline() |
||
1357 | { |
||
1358 | return $this->cancelDeadline; |
||
1359 | } |
||
1360 | |||
1361 | /** |
||
1362 | * Returns if autoconfirmation is enabled |
||
1363 | * |
||
1364 | * @return bool |
||
1365 | */ |
||
1366 | public function getEnableAutoconfirm() |
||
1367 | { |
||
1368 | return $this->enableAutoconfirm; |
||
1369 | } |
||
1370 | |||
1371 | /** |
||
1372 | * Sets enable autoconfirm |
||
1373 | * |
||
1374 | * @param bool $enableAutoconfirm |
||
1375 | */ |
||
1376 | public function setEnableAutoconfirm($enableAutoconfirm) |
||
1377 | { |
||
1378 | $this->enableAutoconfirm = $enableAutoconfirm; |
||
1379 | } |
||
1380 | |||
1381 | /** |
||
1382 | * Returns uniqueEmailCheck |
||
1383 | * |
||
1384 | * @return bool |
||
1385 | */ |
||
1386 | public function getUniqueEmailCheck() |
||
1387 | { |
||
1388 | return $this->uniqueEmailCheck; |
||
1389 | } |
||
1390 | |||
1391 | /** |
||
1392 | * Sets UniqueEmailCheck |
||
1393 | * |
||
1394 | * @param bool $uniqueEmailCheck |
||
1395 | */ |
||
1396 | public function setUniqueEmailCheck($uniqueEmailCheck) |
||
1397 | { |
||
1398 | $this->uniqueEmailCheck = $uniqueEmailCheck; |
||
1399 | } |
||
1400 | |||
1401 | /** |
||
1402 | * Returns price options |
||
1403 | * |
||
1404 | * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\DERHANSEN\SfEventMgt\Domain\Model\PriceOption> |
||
1405 | */ |
||
1406 | public function getPriceOptions() |
||
1407 | { |
||
1408 | return $this->priceOptions; |
||
1409 | } |
||
1410 | |||
1411 | /** |
||
1412 | * Sets price options |
||
1413 | * |
||
1414 | * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $priceOptions |
||
1415 | */ |
||
1416 | public function setPriceOptions($priceOptions) |
||
1417 | { |
||
1418 | $this->priceOptions = $priceOptions; |
||
1419 | } |
||
1420 | |||
1421 | /** |
||
1422 | * Adds a price option |
||
1423 | * |
||
1424 | * @param \DERHANSEN\SfEventMgt\Domain\Model\PriceOption $priceOption Price option |
||
1425 | */ |
||
1426 | public function addPriceOptions(\DERHANSEN\SfEventMgt\Domain\Model\PriceOption $priceOption) |
||
1427 | { |
||
1428 | $this->priceOptions->attach($priceOption); |
||
1429 | } |
||
1430 | |||
1431 | /** |
||
1432 | * Removes a Registration |
||
1433 | * |
||
1434 | * @param \DERHANSEN\SfEventMgt\Domain\Model\PriceOption $priceOption Price option |
||
1435 | */ |
||
1436 | public function removePriceOptions(\DERHANSEN\SfEventMgt\Domain\Model\PriceOption $priceOption) |
||
1437 | { |
||
1438 | $this->priceOptions->detach($priceOption); |
||
1439 | } |
||
1440 | |||
1441 | /** |
||
1442 | * Returns all active price options sorted by date ASC |
||
1443 | * |
||
1444 | * @return array |
||
1445 | */ |
||
1446 | public function getActivePriceOptions() |
||
1447 | { |
||
1448 | $activePriceOptions = []; |
||
1449 | if ($this->getPriceOptions()) { |
||
1450 | $compareDate = new \DateTime('today midnight'); |
||
1451 | foreach ($this->getPriceOptions() as $priceOption) { |
||
1452 | if ($priceOption->getValidUntil() >= $compareDate) { |
||
1453 | $activePriceOptions[$priceOption->getValidUntil()->getTimestamp()] = $priceOption; |
||
1454 | } |
||
1455 | } |
||
1456 | } |
||
1457 | ksort($activePriceOptions); |
||
1458 | |||
1459 | return $activePriceOptions; |
||
1460 | } |
||
1461 | |||
1462 | /** |
||
1463 | * Returns the current price of the event respecting possible price options |
||
1464 | * |
||
1465 | * @return float |
||
1466 | */ |
||
1467 | public function getCurrentPrice() |
||
1468 | { |
||
1469 | $activePriceOptions = $this->getActivePriceOptions(); |
||
1470 | if (count($activePriceOptions) >= 1) { |
||
1471 | // Sort active price options and return first element |
||
1472 | return reset($activePriceOptions)->getPrice(); |
||
1473 | } |
||
1474 | // Just return the price field |
||
1475 | return $this->price; |
||
1476 | } |
||
1477 | |||
1478 | /** |
||
1479 | * Returns registrationWaitlist |
||
1480 | * |
||
1481 | * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage |
||
1482 | */ |
||
1483 | public function getRegistrationWaitlist() |
||
1484 | { |
||
1485 | return $this->registrationWaitlist; |
||
1486 | } |
||
1487 | |||
1488 | /** |
||
1489 | * Sets registrationWaitlist |
||
1490 | * |
||
1491 | * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $registration Registration |
||
1492 | */ |
||
1493 | public function setRegistrationWaitlist(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $registration) |
||
1494 | { |
||
1495 | $this->registrationWaitlist = $registration; |
||
1496 | } |
||
1497 | |||
1498 | /** |
||
1499 | * Adds a Registration to the waitlist |
||
1500 | * |
||
1501 | * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration Registration |
||
1502 | */ |
||
1503 | public function addRegistrationWaitlist(\DERHANSEN\SfEventMgt\Domain\Model\Registration $registration) |
||
1504 | { |
||
1505 | $this->registrationWaitlist->attach($registration); |
||
1506 | } |
||
1507 | |||
1508 | /** |
||
1509 | * Removes a Registration from the waitlist |
||
1510 | * |
||
1511 | * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registrationToRemove Registration |
||
1512 | */ |
||
1513 | public function removeRegistrationWaitlist(\DERHANSEN\SfEventMgt\Domain\Model\Registration $registrationToRemove) |
||
1514 | { |
||
1515 | $this->registrationWaitlist->detach($registrationToRemove); |
||
1516 | } |
||
1517 | |||
1518 | /** |
||
1519 | * Returns, if cancellation for registrations of the event is possible |
||
1520 | * |
||
1521 | * @return bool |
||
1522 | */ |
||
1523 | public function getCancellationPossible() |
||
1524 | { |
||
1525 | $today = new \DateTime('today'); |
||
1526 | |||
1527 | return ($this->getEnableCancel() && $this->getCancelDeadline() > $today) || |
||
1528 | ($this->getEnableCancel() && $this->getCancelDeadline() === null && $this->getStartdate() > $today); |
||
1529 | } |
||
1530 | |||
1531 | /** |
||
1532 | * Returns speaker |
||
1533 | * |
||
1534 | * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage |
||
1535 | */ |
||
1536 | public function getSpeaker() |
||
1537 | { |
||
1538 | return $this->speaker; |
||
1539 | } |
||
1540 | |||
1541 | /** |
||
1542 | * Sets speaker |
||
1543 | * |
||
1544 | * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $speaker |
||
1545 | */ |
||
1546 | public function setSpeaker($speaker) |
||
1547 | { |
||
1548 | $this->speaker = $speaker; |
||
1549 | } |
||
1550 | |||
1551 | /** |
||
1552 | * Adds a speaker |
||
1553 | * |
||
1554 | * @param \DERHANSEN\SfEventMgt\Domain\Model\Speaker $speaker |
||
1555 | */ |
||
1556 | public function addSpeaker(\DERHANSEN\SfEventMgt\Domain\Model\Speaker $speaker) |
||
1557 | { |
||
1558 | $this->speaker->attach($speaker); |
||
1559 | } |
||
1560 | |||
1561 | /** |
||
1562 | * Removes a speaker |
||
1563 | * |
||
1564 | * @param \DERHANSEN\SfEventMgt\Domain\Model\Speaker $speaker |
||
1565 | */ |
||
1566 | public function removeSpeaker(\DERHANSEN\SfEventMgt\Domain\Model\Speaker $speaker) |
||
1567 | { |
||
1568 | $this->speaker->detach($speaker); |
||
1569 | } |
||
1570 | |||
1571 | /** |
||
1572 | * Returns registrationFields |
||
1573 | * |
||
1574 | * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage |
||
1575 | */ |
||
1576 | public function getRegistrationFields() |
||
1577 | { |
||
1578 | return $this->registrationFields; |
||
1579 | } |
||
1580 | |||
1581 | /** |
||
1582 | * Sets registrationWaitlist |
||
1583 | * |
||
1584 | * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $registrationFields |
||
1585 | */ |
||
1586 | public function setRegistrationFields(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $registrationFields) |
||
1587 | { |
||
1588 | $this->registrationFields = $registrationFields; |
||
1589 | } |
||
1590 | |||
1591 | /** |
||
1592 | * Adds a registrationField |
||
1593 | * |
||
1594 | * @param Field $registrationField |
||
1595 | */ |
||
1596 | public function addRegistrationFields(Field $registrationField) |
||
1599 | } |
||
1600 | |||
1601 | /** |
||
1602 | * Removed a registrationField |
||
1603 | * |
||
1604 | * @param Field $registrationField |
||
1605 | */ |
||
1606 | public function removeRegistrationFields(Field $registrationField) |
||
1607 | { |
||
1608 | $this->registrationFields->detach($registrationField); |
||
1609 | } |
||
1610 | |||
1611 | /** |
||
1612 | * Returns an array with registration field uids |
||
1613 | * |
||
1614 | * @return array |
||
1615 | */ |
||
1616 | public function getRegistrationFieldsUids() |
||
1617 | { |
||
1618 | $result = []; |
||
1619 | foreach ($this->registrationFields as $registrationField) { |
||
1620 | $result[] = $registrationField->getUid(); |
||
1621 | } |
||
1622 | |||
1623 | return $result; |
||
1624 | } |
||
1625 | |||
1626 | /** |
||
1627 | * Returns an array with registration field uids and titles |
||
1628 | * [uid => title] |
||
1629 | * |
||
1630 | * @return array |
||
1631 | */ |
||
1632 | public function getRegistrationFieldUidsWithTitle() |
||
1633 | { |
||
1634 | $result = []; |
||
1635 | foreach ($this->registrationFields as $registrationField) { |
||
1636 | $result[$registrationField->getUid()] = $registrationField->getTitle(); |
||
1637 | } |
||
1638 | |||
1639 | return $result; |
||
1640 | } |
||
1641 | |||
1642 | /** |
||
1643 | * Special getter to return the amount of registrations that are saved to default language |
||
1644 | * Required since TYPO3 9.5 (#82363) |
||
1645 | * |
||
1646 | * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage |
||
1647 | */ |
||
1648 | public function getRegistrations() |
||
1649 | { |
||
1650 | $languageAspect = GeneralUtility::makeInstance(Context::class)->getAspect('language'); |
||
1651 | if ($languageAspect->getId() > 0) { |
||
1652 | return $this->getRegistrationsDefaultLanguage(false); |
||
1653 | } |
||
1654 | |||
1655 | return $this->registration; |
||
1656 | } |
||
1657 | |||
1658 | /** |
||
1659 | * Special getter to return the amount of waitlist registrations that are saved to default language |
||
1660 | * Required since TYPO3 9.5 (#82363) |
||
1661 | * |
||
1662 | * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage |
||
1663 | */ |
||
1664 | public function getRegistrationsWaitlist() |
||
1665 | { |
||
1666 | $languageAspect = GeneralUtility::makeInstance(Context::class)->getAspect('language'); |
||
1667 | if ($languageAspect->getId() > 0) { |
||
1668 | return $this->getRegistrationsDefaultLanguage(true); |
||
1669 | } |
||
1670 | |||
1671 | return $this->registrationWaitlist; |
||
1672 | } |
||
1673 | |||
1674 | /** |
||
1675 | * Returns an objectStorage object holding all registrations in the default language. |
||
1676 | * Ensures expected behavior of getRegistration() and getRegistrationWaitlist() since TYPO3 issue #82363 |
||
1677 | * |
||
1678 | * @param bool $waitlist |
||
1679 | * @return ObjectStorage |
||
1680 | */ |
||
1681 | protected function getRegistrationsDefaultLanguage(bool $waitlist = false) |
||
1682 | { |
||
1683 | $objectManager = GeneralUtility::makeInstance(ObjectManager::class); |
||
1684 | $result = $objectManager->get(ObjectStorage::class); |
||
1685 | $registrationRepository = $objectManager->get(RegistrationRepository::class); |
||
1686 | $registrations = $registrationRepository->findByEventAndWaitlist($this, $waitlist); |
||
1687 | foreach ($registrations as $registration) { |
||
1688 | $result->attach($registration); |
||
1689 | } |
||
1690 | |||
1691 | return $result; |
||
1692 | } |
||
1693 | |||
1694 | /** |
||
1695 | * Returns if the event ends on the same day |
||
1696 | * |
||
1697 | * @return bool |
||
1698 | */ |
||
1699 | public function getEndsSameDay(): bool |
||
1706 | } |
||
1707 | |||
1708 | /** |
||
1709 | * Returns the challenge for the challenge/response spam check |
||
1710 | * |
||
1711 | * @return string |
||
1712 | */ |
||
1713 | public function getSpamCheckChallenge(): string |
||
1714 | { |
||
1715 | return MiscUtility::getSpamCheckChallenge($this->getUid()); |
||
1716 | } |
||
1717 | |||
1718 | /** |
||
1719 | * Returns a string to be used as overlay value for the <core:icon> ViewHelper in the Backend Modules |
||
1720 | * |
||
1721 | * @return string |
||
1722 | */ |
||
1723 | public function getBackendIconOverlay(): string |
||
1738 | } |
||
1739 | } |
||
1740 |