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