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