Total Complexity | 176 |
Total Lines | 954 |
Duplicated Lines | 0 % |
Changes | 2 | ||
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 |
||
29 | class Event extends AbstractEntity |
||
30 | { |
||
31 | protected ?DateTime $tstamp = null; |
||
32 | protected bool $hidden = false; |
||
33 | protected ?DateTime $starttime = null; |
||
34 | protected ?DateTime $endtime = null; |
||
35 | protected string $title = ''; |
||
36 | protected string $teaser = ''; |
||
37 | protected string $description = ''; |
||
38 | protected string $program = ''; |
||
39 | protected string $customText = ''; |
||
40 | protected ?DateTime $startdate = null; |
||
41 | protected ?DateTime $enddate = null; |
||
42 | protected int $maxParticipants = 0; |
||
43 | protected int $maxRegistrationsPerUser = 1; |
||
44 | protected float $price = 0.0; |
||
45 | protected string $currency = ''; |
||
46 | protected bool $enablePayment = false; |
||
47 | protected bool $restrictPaymentMethods = false; |
||
48 | protected string $selectedPaymentMethods = ''; |
||
49 | protected ?DateTime $registrationStartdate = null; |
||
50 | protected ?DateTime $registrationDeadline = null; |
||
51 | protected ?Location $location = null; |
||
52 | protected string $room = ''; |
||
53 | protected bool $enableRegistration = false; |
||
54 | protected bool $enableWaitlist = false; |
||
55 | protected bool $enableWaitlistMoveup = false; |
||
56 | protected string $link = ''; |
||
57 | protected bool $topEvent = false; |
||
58 | protected ?Organisator $organisator = null; |
||
59 | protected bool $notifyAdmin = true; |
||
60 | protected bool $notifyOrganisator = false; |
||
61 | protected bool $enableCancel = false; |
||
62 | protected ?DateTime $cancelDeadline = null; |
||
63 | protected bool $enableAutoconfirm = false; |
||
64 | protected bool $uniqueEmailCheck = false; |
||
65 | protected string $metaKeywords = ''; |
||
66 | protected string $metaDescription = ''; |
||
67 | protected string $alternativeTitle = ''; |
||
68 | |||
69 | /** |
||
70 | * @var ObjectStorage<Category> |
||
71 | * @Extbase\ORM\Lazy |
||
72 | */ |
||
73 | protected ObjectStorage $category; |
||
74 | |||
75 | /** |
||
76 | * @var ObjectStorage<Event> |
||
77 | * @Extbase\ORM\Lazy |
||
78 | */ |
||
79 | protected ObjectStorage $related; |
||
80 | |||
81 | /** |
||
82 | * @var ObjectStorage<Registration> |
||
83 | * @Extbase\ORM\Cascade("remove") |
||
84 | * @Extbase\ORM\Lazy |
||
85 | */ |
||
86 | protected ObjectStorage $registration; |
||
87 | |||
88 | /** |
||
89 | * @var ObjectStorage<Registration> |
||
90 | * @Extbase\ORM\Lazy |
||
91 | */ |
||
92 | protected ObjectStorage $registrationWaitlist; |
||
93 | |||
94 | /** |
||
95 | * @var ObjectStorage<Field> |
||
96 | * @Extbase\ORM\Lazy |
||
97 | */ |
||
98 | protected ObjectStorage $registrationFields; |
||
99 | |||
100 | /** |
||
101 | * @var ObjectStorage<FileReference> |
||
102 | * @Extbase\ORM\Lazy |
||
103 | */ |
||
104 | protected ObjectStorage $image; |
||
105 | |||
106 | /** |
||
107 | * @var ObjectStorage<FileReference> |
||
108 | * @Extbase\ORM\Lazy |
||
109 | */ |
||
110 | protected ObjectStorage $files; |
||
111 | |||
112 | /** |
||
113 | * @var ObjectStorage<FileReference> |
||
114 | * @Extbase\ORM\Lazy |
||
115 | */ |
||
116 | protected ObjectStorage $additionalImage; |
||
117 | |||
118 | /** |
||
119 | * @var ObjectStorage<PriceOption> |
||
120 | * @Extbase\ORM\Cascade("remove") |
||
121 | * @Extbase\ORM\Lazy |
||
122 | */ |
||
123 | protected ObjectStorage $priceOptions; |
||
124 | |||
125 | /** |
||
126 | * @var ObjectStorage<Speaker> |
||
127 | * @Extbase\ORM\Lazy |
||
128 | */ |
||
129 | protected ObjectStorage $speaker; |
||
130 | |||
131 | public function __construct() |
||
132 | { |
||
133 | $this->initializeObject(); |
||
134 | } |
||
135 | |||
136 | /** |
||
137 | * Initialize all ObjectStorages as fetching an entity from the DB does not use the constructor |
||
138 | */ |
||
139 | public function initializeObject() |
||
140 | { |
||
141 | $this->category = new ObjectStorage(); |
||
142 | $this->related = new ObjectStorage(); |
||
143 | $this->registration = new ObjectStorage(); |
||
144 | $this->registrationWaitlist = new ObjectStorage(); |
||
145 | $this->registrationFields = new ObjectStorage(); |
||
146 | $this->image = new ObjectStorage(); |
||
147 | $this->files = new ObjectStorage(); |
||
148 | $this->additionalImage = new ObjectStorage(); |
||
149 | $this->priceOptions = new ObjectStorage(); |
||
150 | $this->speaker = new ObjectStorage(); |
||
151 | } |
||
152 | |||
153 | public function getTstamp(): ?DateTime |
||
154 | { |
||
155 | return $this->tstamp; |
||
156 | } |
||
157 | |||
158 | public function setTstamp(?DateTime $tstamp) |
||
159 | { |
||
160 | $this->tstamp = $tstamp; |
||
161 | } |
||
162 | |||
163 | public function getHidden(): bool |
||
164 | { |
||
165 | return $this->hidden; |
||
166 | } |
||
167 | |||
168 | public function setHidden(bool $hidden) |
||
169 | { |
||
170 | $this->hidden = $hidden; |
||
171 | } |
||
172 | |||
173 | public function getStarttime(): ?DateTime |
||
174 | { |
||
175 | return $this->starttime; |
||
176 | } |
||
177 | |||
178 | public function setStarttime(?DateTime $starttime) |
||
179 | { |
||
180 | $this->starttime = $starttime; |
||
181 | } |
||
182 | |||
183 | public function getEndtime(): ?DateTime |
||
184 | { |
||
185 | return $this->endtime; |
||
186 | } |
||
187 | |||
188 | public function setEndtime(?DateTime $endtime) |
||
189 | { |
||
190 | $this->endtime = $endtime; |
||
191 | } |
||
192 | |||
193 | public function getTitle(): string |
||
194 | { |
||
195 | return $this->title; |
||
196 | } |
||
197 | |||
198 | public function setTitle(string $title) |
||
199 | { |
||
200 | $this->title = $title; |
||
201 | } |
||
202 | |||
203 | public function getTeaser(): string |
||
204 | { |
||
205 | return $this->teaser; |
||
206 | } |
||
207 | |||
208 | public function setTeaser(string $teaser) |
||
209 | { |
||
210 | $this->teaser = $teaser; |
||
211 | } |
||
212 | |||
213 | public function getDescription(): string |
||
214 | { |
||
215 | return $this->description; |
||
216 | } |
||
217 | |||
218 | public function setDescription(string $description) |
||
219 | { |
||
220 | $this->description = $description; |
||
221 | } |
||
222 | |||
223 | public function getProgram(): string |
||
224 | { |
||
225 | return $this->program; |
||
226 | } |
||
227 | |||
228 | public function setProgram(string $program) |
||
229 | { |
||
230 | $this->program = $program; |
||
231 | } |
||
232 | |||
233 | public function getCustomText(): string |
||
234 | { |
||
235 | return $this->customText; |
||
236 | } |
||
237 | |||
238 | public function setCustomText(string $customText): void |
||
239 | { |
||
240 | $this->customText = $customText; |
||
241 | } |
||
242 | |||
243 | public function getStartdate(): ?DateTime |
||
244 | { |
||
245 | return $this->startdate; |
||
246 | } |
||
247 | |||
248 | public function setStartdate(?DateTime $startdate) |
||
249 | { |
||
250 | $this->startdate = $startdate; |
||
251 | } |
||
252 | |||
253 | public function getEnddate(): ?DateTime |
||
254 | { |
||
255 | return $this->enddate; |
||
256 | } |
||
257 | |||
258 | public function setEnddate(?DateTime $enddate) |
||
259 | { |
||
260 | $this->enddate = $enddate; |
||
261 | } |
||
262 | |||
263 | public function getMaxParticipants(): int |
||
264 | { |
||
265 | return $this->maxParticipants; |
||
266 | } |
||
267 | |||
268 | public function setMaxParticipants(int $participants) |
||
269 | { |
||
270 | $this->maxParticipants = $participants; |
||
271 | } |
||
272 | |||
273 | public function getPrice(): float |
||
274 | { |
||
275 | return $this->price; |
||
276 | } |
||
277 | |||
278 | public function setPrice(float $price) |
||
279 | { |
||
280 | $this->price = $price; |
||
281 | } |
||
282 | |||
283 | public function getCurrency(): string |
||
284 | { |
||
285 | return $this->currency; |
||
286 | } |
||
287 | |||
288 | public function setCurrency(string $currency) |
||
289 | { |
||
290 | $this->currency = $currency; |
||
291 | } |
||
292 | |||
293 | public function getEnablePayment(): bool |
||
294 | { |
||
295 | return $this->enablePayment; |
||
296 | } |
||
297 | |||
298 | public function setEnablePayment(bool $enablePayment) |
||
299 | { |
||
300 | $this->enablePayment = $enablePayment; |
||
301 | } |
||
302 | |||
303 | public function getRestrictPaymentMethods(): bool |
||
304 | { |
||
305 | return $this->restrictPaymentMethods; |
||
306 | } |
||
307 | |||
308 | public function setRestrictPaymentMethods(bool $restrictPaymentMethods) |
||
309 | { |
||
310 | $this->restrictPaymentMethods = $restrictPaymentMethods; |
||
311 | } |
||
312 | |||
313 | public function getSelectedPaymentMethods(): string |
||
314 | { |
||
315 | return $this->selectedPaymentMethods; |
||
316 | } |
||
317 | |||
318 | public function setSelectedPaymentMethods(string $selectedPaymentMethods) |
||
319 | { |
||
320 | $this->selectedPaymentMethods = $selectedPaymentMethods; |
||
321 | } |
||
322 | |||
323 | public function addCategory(Category $category) |
||
324 | { |
||
325 | $this->category->attach($category); |
||
326 | } |
||
327 | |||
328 | public function removeCategory(Category $categoryToRemove) |
||
329 | { |
||
330 | $this->category->detach($categoryToRemove); |
||
331 | } |
||
332 | |||
333 | public function getCategory(): ?ObjectStorage |
||
334 | { |
||
335 | return $this->category; |
||
336 | } |
||
337 | |||
338 | public function getCategories(): ?ObjectStorage |
||
339 | { |
||
340 | return $this->category; |
||
341 | } |
||
342 | |||
343 | public function setCategory(?ObjectStorage $category) |
||
344 | { |
||
345 | $this->category = $category; |
||
346 | } |
||
347 | |||
348 | public function getRelated(): ?ObjectStorage |
||
349 | { |
||
350 | return $this->related; |
||
351 | } |
||
352 | |||
353 | public function setRelated(?ObjectStorage $related) |
||
354 | { |
||
355 | $this->related = $related; |
||
356 | } |
||
357 | |||
358 | public function addRelated(Event $event) |
||
359 | { |
||
360 | $this->related->attach($event); |
||
361 | } |
||
362 | |||
363 | public function removeRelated(Event $event) |
||
364 | { |
||
365 | $this->related->detach($event); |
||
366 | } |
||
367 | |||
368 | public function addRegistration(Registration $registration) |
||
369 | { |
||
370 | $this->registration->attach($registration); |
||
371 | } |
||
372 | |||
373 | public function removeRegistration(Registration $registrationToRemove) |
||
374 | { |
||
375 | $this->registration->detach($registrationToRemove); |
||
376 | } |
||
377 | |||
378 | public function getRegistration(): ?ObjectStorage |
||
379 | { |
||
380 | return $this->registration; |
||
381 | } |
||
382 | |||
383 | public function setRegistration(?ObjectStorage $registration) |
||
384 | { |
||
385 | $this->registration = $registration; |
||
386 | } |
||
387 | |||
388 | public function addImage(FileReference $image) |
||
389 | { |
||
390 | $this->image->attach($image); |
||
391 | } |
||
392 | |||
393 | public function removeImage(FileReference $imageToRemove) |
||
394 | { |
||
395 | $this->image->detach($imageToRemove); |
||
396 | } |
||
397 | |||
398 | public function getImage(): ?ObjectStorage |
||
399 | { |
||
400 | return $this->image; |
||
401 | } |
||
402 | |||
403 | public function getImages(): ?ObjectStorage |
||
404 | { |
||
405 | return $this->image; |
||
406 | } |
||
407 | |||
408 | public function getListViewImages(): ?ObjectStorage |
||
409 | { |
||
410 | return $this->getImagesByType(ShowInPreviews::LIST_VIEWS); |
||
411 | } |
||
412 | |||
413 | public function getFirstListViewImage(): ?FileReference |
||
414 | { |
||
415 | $images = $this->getImagesByType(ShowInPreviews::LIST_VIEWS); |
||
416 | $image = $images->current(); |
||
417 | |||
418 | if (is_a($image, FileReference::class)) { |
||
419 | return $image; |
||
420 | } |
||
421 | return null; |
||
422 | } |
||
423 | |||
424 | public function getDetailViewImages(): ?ObjectStorage |
||
425 | { |
||
426 | return $this->getImagesByType(ShowInPreviews::DETAIL_VIEWS); |
||
427 | } |
||
428 | |||
429 | public function getFirstDetailViewImage(): ?FileReference |
||
430 | { |
||
431 | $images = $this->getImagesByType(ShowInPreviews::DETAIL_VIEWS); |
||
432 | $image = $images->current(); |
||
433 | |||
434 | if (is_a($image, FileReference::class)) { |
||
435 | return $image; |
||
436 | } |
||
437 | return null; |
||
438 | } |
||
439 | |||
440 | protected function getImagesByType(int $type): ?ObjectStorage |
||
441 | { |
||
442 | $result = new ObjectStorage(); |
||
443 | |||
444 | foreach ($this->image as $image) { |
||
445 | /** @var \TYPO3\CMS\Core\Resource\FileReference $fileReference */ |
||
446 | $fileReference = $image->getOriginalResource(); |
||
447 | if ($fileReference !== null && $fileReference->hasProperty('show_in_views') && |
||
448 | in_array($fileReference->getProperty('show_in_views'), [$type, ShowInPreviews::ALL_VIEWS]) |
||
449 | ) { |
||
450 | $result->attach($image); |
||
451 | } |
||
452 | } |
||
453 | |||
454 | return $result; |
||
455 | } |
||
456 | |||
457 | public function setImage(?ObjectStorage $image) |
||
458 | { |
||
459 | $this->image = $image; |
||
460 | } |
||
461 | |||
462 | public function addFiles(FileReference $file) |
||
463 | { |
||
464 | $this->files->attach($file); |
||
465 | } |
||
466 | |||
467 | public function removeFiles(FileReference $fileToRemove) |
||
468 | { |
||
469 | $this->files->detach($fileToRemove); |
||
470 | } |
||
471 | |||
472 | public function getFiles(): ?ObjectStorage |
||
473 | { |
||
474 | return $this->files; |
||
475 | } |
||
476 | |||
477 | public function setFiles(?ObjectStorage $files) |
||
478 | { |
||
479 | $this->files = $files; |
||
480 | } |
||
481 | |||
482 | /** |
||
483 | * Returns if the registration for this event is logically possible |
||
484 | * |
||
485 | * @return bool |
||
486 | */ |
||
487 | public function getRegistrationPossible(): bool |
||
505 | } |
||
506 | |||
507 | /** |
||
508 | * Returns the amount of free places |
||
509 | * |
||
510 | * @return int |
||
511 | */ |
||
512 | public function getFreePlaces(): int |
||
513 | { |
||
514 | return $this->maxParticipants - $this->getRegistrations()->count(); |
||
515 | } |
||
516 | |||
517 | public function setLocation(?Location $location) |
||
518 | { |
||
519 | $this->location = $location; |
||
520 | } |
||
521 | |||
522 | public function getLocation(): ?Location |
||
523 | { |
||
524 | return $this->location; |
||
525 | } |
||
526 | |||
527 | public function getRoom(): string |
||
528 | { |
||
529 | return $this->room; |
||
530 | } |
||
531 | |||
532 | public function setRoom(string $room) |
||
533 | { |
||
534 | $this->room = $room; |
||
535 | } |
||
536 | |||
537 | public function setEnableRegistration(bool $enableRegistration) |
||
538 | { |
||
539 | $this->enableRegistration = $enableRegistration; |
||
540 | } |
||
541 | |||
542 | public function getEnableRegistration(): bool |
||
543 | { |
||
544 | return $this->enableRegistration; |
||
545 | } |
||
546 | |||
547 | public function getEnableWaitlist(): bool |
||
548 | { |
||
549 | return $this->enableWaitlist; |
||
550 | } |
||
551 | |||
552 | public function setEnableWaitlist(bool $enableWaitlist) |
||
553 | { |
||
554 | $this->enableWaitlist = $enableWaitlist; |
||
555 | } |
||
556 | |||
557 | public function getEnableWaitlistMoveup(): bool |
||
558 | { |
||
559 | return $this->enableWaitlistMoveup; |
||
560 | } |
||
561 | |||
562 | public function setEnableWaitlistMoveup(bool $enableWaitlistMoveup): void |
||
563 | { |
||
564 | $this->enableWaitlistMoveup = $enableWaitlistMoveup; |
||
565 | } |
||
566 | |||
567 | public function setRegistrationStartdate(?DateTime $registrationStartdate) |
||
568 | { |
||
569 | $this->registrationStartdate = $registrationStartdate; |
||
570 | } |
||
571 | |||
572 | public function getRegistrationStartdate(): ?DateTime |
||
573 | { |
||
574 | return $this->registrationStartdate; |
||
575 | } |
||
576 | |||
577 | public function setRegistrationDeadline(?DateTime $registrationDeadline) |
||
578 | { |
||
579 | $this->registrationDeadline = $registrationDeadline; |
||
580 | } |
||
581 | |||
582 | public function getRegistrationDeadline(): ?DateTime |
||
583 | { |
||
584 | return $this->registrationDeadline; |
||
585 | } |
||
586 | |||
587 | public function setLink(string $link) |
||
588 | { |
||
589 | $this->link = $link; |
||
590 | } |
||
591 | |||
592 | public function getLink(): string |
||
593 | { |
||
594 | return $this->link; |
||
595 | } |
||
596 | |||
597 | public function setTopEvent(bool $topEvent) |
||
598 | { |
||
599 | $this->topEvent = $topEvent; |
||
600 | } |
||
601 | |||
602 | public function getTopEvent(): bool |
||
603 | { |
||
604 | return $this->topEvent; |
||
605 | } |
||
606 | |||
607 | public function getMaxRegistrationsPerUser(): int |
||
608 | { |
||
609 | return $this->maxRegistrationsPerUser; |
||
610 | } |
||
611 | |||
612 | public function setMaxRegistrationsPerUser(int $maxRegistrationsPerUser) |
||
613 | { |
||
614 | $this->maxRegistrationsPerUser = $maxRegistrationsPerUser; |
||
615 | } |
||
616 | |||
617 | public function addAdditionalImage(FileReference $additionalImage) |
||
618 | { |
||
619 | $this->additionalImage->attach($additionalImage); |
||
620 | } |
||
621 | |||
622 | public function removeAdditionalImage(FileReference $additionalImageToRemove) |
||
623 | { |
||
624 | $this->additionalImage->detach($additionalImageToRemove); |
||
625 | } |
||
626 | |||
627 | public function getAdditionalImage(): ?ObjectStorage |
||
628 | { |
||
629 | return $this->additionalImage; |
||
630 | } |
||
631 | |||
632 | public function setAdditionalImage(?ObjectStorage $additionalImage) |
||
633 | { |
||
634 | $this->additionalImage = $additionalImage; |
||
635 | } |
||
636 | |||
637 | public function getOrganisator(): ?Organisator |
||
638 | { |
||
639 | return $this->organisator; |
||
640 | } |
||
641 | |||
642 | public function setOrganisator(Organisator $organisator) |
||
643 | { |
||
644 | $this->organisator = $organisator; |
||
645 | } |
||
646 | |||
647 | public function getNotifyAdmin(): bool |
||
648 | { |
||
649 | return $this->notifyAdmin; |
||
650 | } |
||
651 | |||
652 | public function setNotifyAdmin(bool $notifyAdmin) |
||
653 | { |
||
654 | $this->notifyAdmin = $notifyAdmin; |
||
655 | } |
||
656 | |||
657 | public function getNotifyOrganisator(): bool |
||
658 | { |
||
659 | return $this->notifyOrganisator; |
||
660 | } |
||
661 | |||
662 | public function setNotifyOrganisator(bool $notifyOrganisator) |
||
663 | { |
||
664 | $this->notifyOrganisator = $notifyOrganisator; |
||
665 | } |
||
666 | |||
667 | public function setEnableCancel(bool $enableCancel) |
||
668 | { |
||
669 | $this->enableCancel = $enableCancel; |
||
670 | } |
||
671 | |||
672 | public function getEnableCancel(): bool |
||
673 | { |
||
674 | return $this->enableCancel; |
||
675 | } |
||
676 | |||
677 | public function setCancelDeadline(?DateTime $cancelDeadline) |
||
678 | { |
||
679 | $this->cancelDeadline = $cancelDeadline; |
||
680 | } |
||
681 | |||
682 | public function getCancelDeadline(): ?DateTime |
||
683 | { |
||
684 | return $this->cancelDeadline; |
||
685 | } |
||
686 | |||
687 | public function getEnableAutoconfirm(): bool |
||
688 | { |
||
689 | return $this->enableAutoconfirm; |
||
690 | } |
||
691 | |||
692 | public function setEnableAutoconfirm(bool $enableAutoconfirm) |
||
693 | { |
||
694 | $this->enableAutoconfirm = $enableAutoconfirm; |
||
695 | } |
||
696 | |||
697 | public function getUniqueEmailCheck(): bool |
||
698 | { |
||
699 | return $this->uniqueEmailCheck; |
||
700 | } |
||
701 | |||
702 | public function setUniqueEmailCheck(bool $uniqueEmailCheck) |
||
703 | { |
||
704 | $this->uniqueEmailCheck = $uniqueEmailCheck; |
||
705 | } |
||
706 | |||
707 | public function getMetaKeywords(): string |
||
708 | { |
||
709 | return $this->metaKeywords; |
||
710 | } |
||
711 | |||
712 | public function setMetaKeywords(string $metaKeywords): void |
||
713 | { |
||
714 | $this->metaKeywords = $metaKeywords; |
||
715 | } |
||
716 | |||
717 | public function getMetaDescription(): string |
||
718 | { |
||
719 | return $this->metaDescription; |
||
720 | } |
||
721 | |||
722 | public function setMetaDescription(string $metaDescription): void |
||
723 | { |
||
724 | $this->metaDescription = $metaDescription; |
||
725 | } |
||
726 | |||
727 | public function getAlternativeTitle(): string |
||
728 | { |
||
729 | return $this->alternativeTitle; |
||
730 | } |
||
731 | |||
732 | public function setAlternativeTitle(string $alternativeTitle): void |
||
735 | } |
||
736 | |||
737 | public function getMetaTitle(): string |
||
738 | { |
||
739 | return $this->getAlternativeTitle() !== '' ? $this->getAlternativeTitle() : $this->getTitle(); |
||
740 | } |
||
741 | |||
742 | public function getPriceOptions(): ?ObjectStorage |
||
743 | { |
||
744 | return $this->priceOptions; |
||
745 | } |
||
746 | |||
747 | public function setPriceOptions(?ObjectStorage $priceOptions) |
||
748 | { |
||
749 | $this->priceOptions = $priceOptions; |
||
750 | } |
||
751 | |||
752 | public function addPriceOptions(PriceOption $priceOption) |
||
753 | { |
||
754 | $this->priceOptions->attach($priceOption); |
||
755 | } |
||
756 | |||
757 | public function removePriceOptions(PriceOption $priceOption) |
||
758 | { |
||
759 | $this->priceOptions->detach($priceOption); |
||
760 | } |
||
761 | |||
762 | /** |
||
763 | * Returns all active price options sorted by date ASC |
||
764 | * |
||
765 | * @return array |
||
766 | */ |
||
767 | public function getActivePriceOptions(): array |
||
768 | { |
||
769 | $activePriceOptions = []; |
||
770 | if ($this->getPriceOptions()) { |
||
771 | $compareDate = new DateTime('today midnight'); |
||
772 | foreach ($this->getPriceOptions() as $priceOption) { |
||
773 | if ($priceOption->getValidUntil() >= $compareDate) { |
||
774 | $activePriceOptions[$priceOption->getValidUntil()->getTimestamp()] = $priceOption; |
||
775 | } |
||
776 | } |
||
777 | } |
||
778 | ksort($activePriceOptions); |
||
779 | |||
780 | return $activePriceOptions; |
||
781 | } |
||
782 | |||
783 | /** |
||
784 | * Returns the current price of the event respecting possible price options |
||
785 | * |
||
786 | * @return float |
||
787 | */ |
||
788 | public function getCurrentPrice(): float |
||
789 | { |
||
790 | $activePriceOptions = $this->getActivePriceOptions(); |
||
791 | if (count($activePriceOptions) >= 1) { |
||
792 | // Sort active price options and return first element |
||
793 | return reset($activePriceOptions)->getPrice(); |
||
794 | } |
||
795 | // Just return the price field |
||
796 | return $this->price; |
||
797 | } |
||
798 | |||
799 | public function getRegistrationWaitlist(): ?ObjectStorage |
||
800 | { |
||
801 | return $this->registrationWaitlist; |
||
802 | } |
||
803 | |||
804 | public function setRegistrationWaitlist(?ObjectStorage $registration) |
||
805 | { |
||
806 | $this->registrationWaitlist = $registration; |
||
807 | } |
||
808 | |||
809 | public function addRegistrationWaitlist(Registration $registration) |
||
810 | { |
||
811 | $this->registrationWaitlist->attach($registration); |
||
812 | } |
||
813 | |||
814 | public function removeRegistrationWaitlist(Registration $registrationToRemove) |
||
815 | { |
||
816 | $this->registrationWaitlist->detach($registrationToRemove); |
||
817 | } |
||
818 | |||
819 | /** |
||
820 | * Returns, if cancellation for registrations of the event is possible |
||
821 | * |
||
822 | * @return bool |
||
823 | */ |
||
824 | public function getCancellationPossible(): bool |
||
825 | { |
||
826 | $today = new DateTime('today'); |
||
827 | |||
828 | return ($this->getEnableCancel() && $this->getCancelDeadline() > $today) || |
||
829 | ($this->getEnableCancel() && $this->getCancelDeadline() === null && $this->getStartdate() > $today); |
||
830 | } |
||
831 | |||
832 | public function getSpeaker(): ?ObjectStorage |
||
833 | { |
||
834 | return $this->speaker; |
||
835 | } |
||
836 | |||
837 | public function setSpeaker(?ObjectStorage $speaker) |
||
838 | { |
||
839 | $this->speaker = $speaker; |
||
840 | } |
||
841 | |||
842 | public function addSpeaker(Speaker $speaker) |
||
843 | { |
||
844 | $this->speaker->attach($speaker); |
||
845 | } |
||
846 | |||
847 | public function removeSpeaker(Speaker $speaker) |
||
848 | { |
||
849 | $this->speaker->detach($speaker); |
||
850 | } |
||
851 | |||
852 | public function getRegistrationFields(): ?ObjectStorage |
||
853 | { |
||
854 | return $this->registrationFields; |
||
855 | } |
||
856 | |||
857 | public function setRegistrationFields(?ObjectStorage $registrationFields) |
||
858 | { |
||
859 | $this->registrationFields = $registrationFields; |
||
860 | } |
||
861 | |||
862 | public function addRegistrationFields(Field $registrationField) |
||
865 | } |
||
866 | |||
867 | public function removeRegistrationFields(Field $registrationField) |
||
868 | { |
||
869 | $this->registrationFields->detach($registrationField); |
||
870 | } |
||
871 | |||
872 | public function getRegistrationFieldsUids(): array |
||
873 | { |
||
874 | $result = []; |
||
875 | foreach ($this->registrationFields as $registrationField) { |
||
876 | $result[] = $registrationField->getUid(); |
||
877 | } |
||
878 | |||
879 | return $result; |
||
880 | } |
||
881 | |||
882 | /** |
||
883 | * Returns an array with registration field uids and titles |
||
884 | * [uid => title] |
||
885 | * |
||
886 | * @return array |
||
887 | */ |
||
888 | public function getRegistrationFieldUidsWithTitle(): array |
||
889 | { |
||
890 | $result = []; |
||
891 | foreach ($this->registrationFields as $registrationField) { |
||
892 | $result[$registrationField->getUid()] = $registrationField->getTitle(); |
||
893 | } |
||
894 | |||
895 | return $result; |
||
896 | } |
||
897 | |||
898 | /** |
||
899 | * Special getter to return the amount of registrations that are saved to default language |
||
900 | * Required since TYPO3 9.5 (#82363) |
||
901 | * |
||
902 | * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage |
||
903 | */ |
||
904 | public function getRegistrations(): ?ObjectStorage |
||
905 | { |
||
906 | $languageAspect = GeneralUtility::makeInstance(Context::class)->getAspect('language'); |
||
907 | if ($languageAspect->getId() > 0) { |
||
908 | return $this->getRegistrationsDefaultLanguage(false); |
||
909 | } |
||
910 | |||
911 | return $this->registration; |
||
912 | } |
||
913 | |||
914 | /** |
||
915 | * Special getter to return the amount of waitlist registrations that are saved to default language |
||
916 | * Required since TYPO3 9.5 (#82363) |
||
917 | * |
||
918 | * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage |
||
919 | */ |
||
920 | public function getRegistrationsWaitlist(): ?ObjectStorage |
||
921 | { |
||
922 | $languageAspect = GeneralUtility::makeInstance(Context::class)->getAspect('language'); |
||
923 | if ($languageAspect->getId() > 0) { |
||
924 | return $this->getRegistrationsDefaultLanguage(true); |
||
925 | } |
||
926 | |||
927 | return $this->registrationWaitlist; |
||
928 | } |
||
929 | |||
930 | /** |
||
931 | * Returns an objectStorage object holding all registrations in the default language. |
||
932 | * Ensures expected behavior of getRegistration() and getRegistrationWaitlist() since TYPO3 issue #82363 |
||
933 | * |
||
934 | * @param bool $waitlist |
||
935 | * @return ObjectStorage |
||
936 | */ |
||
937 | protected function getRegistrationsDefaultLanguage(bool $waitlist = false): ObjectStorage |
||
938 | { |
||
939 | $result = GeneralUtility::makeInstance(ObjectStorage::class); |
||
940 | $registrationRepository = GeneralUtility::makeInstance(RegistrationRepository::class); |
||
941 | $registrations = $registrationRepository->findByEventAndWaitlist($this, $waitlist); |
||
942 | foreach ($registrations as $registration) { |
||
943 | $result->attach($registration); |
||
944 | } |
||
945 | |||
946 | return $result; |
||
947 | } |
||
948 | |||
949 | public function getEndsSameDay(): bool |
||
956 | } |
||
957 | |||
958 | public function getSpamCheckChallenge(): string |
||
959 | { |
||
960 | return MiscUtility::getSpamCheckChallenge($this->getUid()); |
||
961 | } |
||
962 | |||
963 | /** |
||
964 | * Returns a string to be used as overlay value for the <core:icon> ViewHelper in the Backend Modules |
||
965 | * |
||
966 | * @return string |
||
967 | */ |
||
968 | public function getBackendIconOverlay(): string |
||
983 | } |
||
984 | } |
||
985 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.