| Total Complexity | 191 |
| Total Lines | 993 |
| 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 bool $allowRegistrationUntilEnddate = false; |
||
| 49 | protected ?Location $location = null; |
||
| 50 | protected string $room = ''; |
||
| 51 | protected bool $enableRegistration = false; |
||
| 52 | protected bool $enableWaitlist = false; |
||
| 53 | protected bool $enableWaitlistMoveup = false; |
||
| 54 | protected string $link = ''; |
||
| 55 | protected bool $topEvent = false; |
||
| 56 | protected ?Organisator $organisator = null; |
||
| 57 | protected bool $notifyAdmin = true; |
||
| 58 | protected bool $notifyOrganisator = false; |
||
| 59 | protected bool $enableCancel = false; |
||
| 60 | protected ?DateTime $cancelDeadline = null; |
||
| 61 | protected bool $enableAutoconfirm = false; |
||
| 62 | protected bool $uniqueEmailCheck = false; |
||
| 63 | protected string $metaKeywords = ''; |
||
| 64 | protected string $metaDescription = ''; |
||
| 65 | protected string $alternativeTitle = ''; |
||
| 66 | |||
| 67 | /** |
||
| 68 | * @var ObjectStorage<Category> |
||
| 69 | * @Extbase\ORM\Lazy |
||
| 70 | */ |
||
| 71 | protected ObjectStorage $category; |
||
| 72 | |||
| 73 | /** |
||
| 74 | * @var ObjectStorage<Event> |
||
| 75 | * @Extbase\ORM\Lazy |
||
| 76 | */ |
||
| 77 | protected ObjectStorage $related; |
||
| 78 | |||
| 79 | /** |
||
| 80 | * @var ObjectStorage<Registration> |
||
| 81 | * @Extbase\ORM\Cascade("remove") |
||
| 82 | * @Extbase\ORM\Lazy |
||
| 83 | */ |
||
| 84 | protected ObjectStorage $registration; |
||
| 85 | |||
| 86 | /** |
||
| 87 | * @var ObjectStorage<Registration> |
||
| 88 | * @Extbase\ORM\Lazy |
||
| 89 | */ |
||
| 90 | protected ObjectStorage $registrationWaitlist; |
||
| 91 | |||
| 92 | /** |
||
| 93 | * @var ObjectStorage<Field> |
||
| 94 | * @Extbase\ORM\Lazy |
||
| 95 | */ |
||
| 96 | protected ObjectStorage $registrationFields; |
||
| 97 | |||
| 98 | /** |
||
| 99 | * @var ObjectStorage<FileReference> |
||
| 100 | * @Extbase\ORM\Lazy |
||
| 101 | */ |
||
| 102 | protected ObjectStorage $image; |
||
| 103 | |||
| 104 | /** |
||
| 105 | * @var ObjectStorage<FileReference> |
||
| 106 | * @Extbase\ORM\Lazy |
||
| 107 | */ |
||
| 108 | protected ObjectStorage $files; |
||
| 109 | |||
| 110 | /** |
||
| 111 | * @var ObjectStorage<FileReference> |
||
| 112 | * @Extbase\ORM\Lazy |
||
| 113 | */ |
||
| 114 | protected ObjectStorage $additionalImage; |
||
| 115 | |||
| 116 | /** |
||
| 117 | * @var ObjectStorage<PriceOption> |
||
| 118 | * @Extbase\ORM\Cascade("remove") |
||
| 119 | * @Extbase\ORM\Lazy |
||
| 120 | */ |
||
| 121 | protected ObjectStorage $priceOptions; |
||
| 122 | |||
| 123 | /** |
||
| 124 | * @var ObjectStorage<Speaker> |
||
| 125 | * @Extbase\ORM\Lazy |
||
| 126 | */ |
||
| 127 | protected ObjectStorage $speaker; |
||
| 128 | |||
| 129 | public function __construct() |
||
| 130 | { |
||
| 131 | $this->initializeObject(); |
||
| 132 | } |
||
| 133 | |||
| 134 | /** |
||
| 135 | * Initialize all ObjectStorages as fetching an entity from the DB does not use the constructor |
||
| 136 | */ |
||
| 137 | public function initializeObject(): void |
||
| 138 | { |
||
| 139 | $this->category = new ObjectStorage(); |
||
| 140 | $this->related = new ObjectStorage(); |
||
| 141 | $this->registration = new ObjectStorage(); |
||
| 142 | $this->registrationWaitlist = new ObjectStorage(); |
||
| 143 | $this->registrationFields = new ObjectStorage(); |
||
| 144 | $this->image = new ObjectStorage(); |
||
| 145 | $this->files = new ObjectStorage(); |
||
| 146 | $this->additionalImage = new ObjectStorage(); |
||
| 147 | $this->priceOptions = new ObjectStorage(); |
||
| 148 | $this->speaker = new ObjectStorage(); |
||
| 149 | } |
||
| 150 | |||
| 151 | public function getTstamp(): ?DateTime |
||
| 152 | { |
||
| 153 | return $this->tstamp; |
||
| 154 | } |
||
| 155 | |||
| 156 | public function setTstamp(?DateTime $tstamp): void |
||
| 157 | { |
||
| 158 | $this->tstamp = $tstamp; |
||
| 159 | } |
||
| 160 | |||
| 161 | public function getHidden(): bool |
||
| 162 | { |
||
| 163 | return $this->hidden; |
||
| 164 | } |
||
| 165 | |||
| 166 | public function setHidden(bool $hidden): void |
||
| 167 | { |
||
| 168 | $this->hidden = $hidden; |
||
| 169 | } |
||
| 170 | |||
| 171 | public function getStarttime(): ?DateTime |
||
| 172 | { |
||
| 173 | return $this->starttime; |
||
| 174 | } |
||
| 175 | |||
| 176 | public function setStarttime(?DateTime $starttime): void |
||
| 177 | { |
||
| 178 | $this->starttime = $starttime; |
||
| 179 | } |
||
| 180 | |||
| 181 | public function getEndtime(): ?DateTime |
||
| 182 | { |
||
| 183 | return $this->endtime; |
||
| 184 | } |
||
| 185 | |||
| 186 | public function setEndtime(?DateTime $endtime): void |
||
| 187 | { |
||
| 188 | $this->endtime = $endtime; |
||
| 189 | } |
||
| 190 | |||
| 191 | public function getTitle(): string |
||
| 192 | { |
||
| 193 | return $this->title; |
||
| 194 | } |
||
| 195 | |||
| 196 | public function setTitle(string $title): void |
||
| 197 | { |
||
| 198 | $this->title = $title; |
||
| 199 | } |
||
| 200 | |||
| 201 | public function getTeaser(): string |
||
| 202 | { |
||
| 203 | return $this->teaser; |
||
| 204 | } |
||
| 205 | |||
| 206 | public function setTeaser(string $teaser): void |
||
| 207 | { |
||
| 208 | $this->teaser = $teaser; |
||
| 209 | } |
||
| 210 | |||
| 211 | public function getDescription(): string |
||
| 212 | { |
||
| 213 | return $this->description; |
||
| 214 | } |
||
| 215 | |||
| 216 | public function setDescription(string $description): void |
||
| 217 | { |
||
| 218 | $this->description = $description; |
||
| 219 | } |
||
| 220 | |||
| 221 | public function getProgram(): string |
||
| 222 | { |
||
| 223 | return $this->program; |
||
| 224 | } |
||
| 225 | |||
| 226 | public function setProgram(string $program): void |
||
| 227 | { |
||
| 228 | $this->program = $program; |
||
| 229 | } |
||
| 230 | |||
| 231 | public function getCustomText(): string |
||
| 232 | { |
||
| 233 | return $this->customText; |
||
| 234 | } |
||
| 235 | |||
| 236 | public function setCustomText(string $customText): void |
||
| 237 | { |
||
| 238 | $this->customText = $customText; |
||
| 239 | } |
||
| 240 | |||
| 241 | public function getStartdate(): ?DateTime |
||
| 242 | { |
||
| 243 | return $this->startdate; |
||
| 244 | } |
||
| 245 | |||
| 246 | public function setStartdate(?DateTime $startdate): void |
||
| 247 | { |
||
| 248 | $this->startdate = $startdate; |
||
| 249 | } |
||
| 250 | |||
| 251 | public function getEnddate(): ?DateTime |
||
| 252 | { |
||
| 253 | return $this->enddate; |
||
| 254 | } |
||
| 255 | |||
| 256 | public function setEnddate(?DateTime $enddate): void |
||
| 257 | { |
||
| 258 | $this->enddate = $enddate; |
||
| 259 | } |
||
| 260 | |||
| 261 | public function getMaxParticipants(): int |
||
| 262 | { |
||
| 263 | return $this->maxParticipants; |
||
| 264 | } |
||
| 265 | |||
| 266 | public function setMaxParticipants(int $participants): void |
||
| 269 | } |
||
| 270 | |||
| 271 | public function getPrice(): float |
||
| 272 | { |
||
| 273 | return $this->price; |
||
| 274 | } |
||
| 275 | |||
| 276 | public function setPrice(float $price): void |
||
| 277 | { |
||
| 278 | $this->price = $price; |
||
| 279 | } |
||
| 280 | |||
| 281 | public function getCurrency(): string |
||
| 282 | { |
||
| 283 | return $this->currency; |
||
| 284 | } |
||
| 285 | |||
| 286 | public function setCurrency(string $currency): void |
||
| 287 | { |
||
| 288 | $this->currency = $currency; |
||
| 289 | } |
||
| 290 | |||
| 291 | public function getEnablePayment(): bool |
||
| 292 | { |
||
| 293 | return $this->enablePayment; |
||
| 294 | } |
||
| 295 | |||
| 296 | public function setEnablePayment(bool $enablePayment): void |
||
| 297 | { |
||
| 298 | $this->enablePayment = $enablePayment; |
||
| 299 | } |
||
| 300 | |||
| 301 | public function getRestrictPaymentMethods(): bool |
||
| 304 | } |
||
| 305 | |||
| 306 | public function setRestrictPaymentMethods(bool $restrictPaymentMethods): void |
||
| 307 | { |
||
| 308 | $this->restrictPaymentMethods = $restrictPaymentMethods; |
||
| 309 | } |
||
| 310 | |||
| 311 | public function getSelectedPaymentMethods(): string |
||
| 312 | { |
||
| 313 | return $this->selectedPaymentMethods; |
||
| 314 | } |
||
| 315 | |||
| 316 | public function setSelectedPaymentMethods(string $selectedPaymentMethods): void |
||
| 319 | } |
||
| 320 | |||
| 321 | public function addCategory(Category $category): void |
||
| 322 | { |
||
| 323 | $this->category->attach($category); |
||
| 324 | } |
||
| 325 | |||
| 326 | public function removeCategory(Category $categoryToRemove): void |
||
| 327 | { |
||
| 328 | $this->category->detach($categoryToRemove); |
||
| 329 | } |
||
| 330 | |||
| 331 | public function getCategory(): ?ObjectStorage |
||
| 334 | } |
||
| 335 | |||
| 336 | public function getCategories(): ?ObjectStorage |
||
| 337 | { |
||
| 338 | return $this->category; |
||
| 339 | } |
||
| 340 | |||
| 341 | public function setCategory(?ObjectStorage $category): void |
||
| 342 | { |
||
| 343 | $this->category = $category; |
||
| 344 | } |
||
| 345 | |||
| 346 | public function getRelated(): ?ObjectStorage |
||
| 347 | { |
||
| 348 | return $this->related; |
||
| 349 | } |
||
| 350 | |||
| 351 | public function setRelated(?ObjectStorage $related): void |
||
| 352 | { |
||
| 353 | $this->related = $related; |
||
| 354 | } |
||
| 355 | |||
| 356 | public function addRelated(Event $event): void |
||
| 357 | { |
||
| 358 | $this->related->attach($event); |
||
| 359 | } |
||
| 360 | |||
| 361 | public function removeRelated(Event $event): void |
||
| 362 | { |
||
| 363 | $this->related->detach($event); |
||
| 364 | } |
||
| 365 | |||
| 366 | public function addRegistration(Registration $registration): void |
||
| 367 | { |
||
| 368 | $this->registration->attach($registration); |
||
| 369 | } |
||
| 370 | |||
| 371 | public function removeRegistration(Registration $registrationToRemove): void |
||
| 372 | { |
||
| 373 | $this->registration->detach($registrationToRemove); |
||
| 374 | } |
||
| 375 | |||
| 376 | public function getRegistration(): ?ObjectStorage |
||
| 377 | { |
||
| 378 | return $this->registration; |
||
| 379 | } |
||
| 380 | |||
| 381 | public function setRegistration(?ObjectStorage $registration): void |
||
| 382 | { |
||
| 383 | $this->registration = $registration; |
||
| 384 | } |
||
| 385 | |||
| 386 | public function addImage(FileReference $image): void |
||
| 387 | { |
||
| 388 | $this->image->attach($image); |
||
| 389 | } |
||
| 390 | |||
| 391 | public function removeImage(FileReference $imageToRemove): void |
||
| 392 | { |
||
| 393 | $this->image->detach($imageToRemove); |
||
| 394 | } |
||
| 395 | |||
| 396 | public function getImage(): ?ObjectStorage |
||
| 397 | { |
||
| 398 | return $this->image; |
||
| 399 | } |
||
| 400 | |||
| 401 | public function getImages(): ?ObjectStorage |
||
| 402 | { |
||
| 403 | return $this->image; |
||
| 404 | } |
||
| 405 | |||
| 406 | public function getListViewImages(): ?ObjectStorage |
||
| 407 | { |
||
| 408 | return $this->getImagesByType(ShowInPreviews::LIST_VIEWS); |
||
| 409 | } |
||
| 410 | |||
| 411 | public function getFirstListViewImage(): ?FileReference |
||
| 412 | { |
||
| 413 | $images = $this->getImagesByType(ShowInPreviews::LIST_VIEWS); |
||
| 414 | $image = $images->current(); |
||
| 415 | |||
| 416 | if (is_a($image, FileReference::class)) { |
||
| 417 | return $image; |
||
| 418 | } |
||
| 419 | return null; |
||
| 420 | } |
||
| 421 | |||
| 422 | public function getDetailViewImages(): ?ObjectStorage |
||
| 423 | { |
||
| 424 | return $this->getImagesByType(ShowInPreviews::DETAIL_VIEWS); |
||
| 425 | } |
||
| 426 | |||
| 427 | public function getFirstDetailViewImage(): ?FileReference |
||
| 428 | { |
||
| 429 | $images = $this->getImagesByType(ShowInPreviews::DETAIL_VIEWS); |
||
| 430 | $image = $images->current(); |
||
| 431 | |||
| 432 | if (is_a($image, FileReference::class)) { |
||
| 433 | return $image; |
||
| 434 | } |
||
| 435 | return null; |
||
| 436 | } |
||
| 437 | |||
| 438 | protected function getImagesByType(int $type): ?ObjectStorage |
||
| 439 | { |
||
| 440 | $result = new ObjectStorage(); |
||
| 441 | |||
| 442 | foreach ($this->image as $image) { |
||
| 443 | /** @var \TYPO3\CMS\Core\Resource\FileReference $fileReference */ |
||
| 444 | $fileReference = $image->getOriginalResource(); |
||
| 445 | if ($fileReference !== null && $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 | public function getPriceOptions(): ?ObjectStorage |
||
| 762 | { |
||
| 763 | return $this->priceOptions; |
||
| 764 | } |
||
| 765 | |||
| 766 | public function setPriceOptions(?ObjectStorage $priceOptions): void |
||
| 767 | { |
||
| 768 | $this->priceOptions = $priceOptions; |
||
| 769 | } |
||
| 770 | |||
| 771 | public function addPriceOptions(PriceOption $priceOption): void |
||
| 772 | { |
||
| 773 | $this->priceOptions->attach($priceOption); |
||
| 774 | } |
||
| 775 | |||
| 776 | public function removePriceOptions(PriceOption $priceOption): void |
||
| 777 | { |
||
| 778 | $this->priceOptions->detach($priceOption); |
||
| 779 | } |
||
| 780 | |||
| 781 | /** |
||
| 782 | * Returns all active price options sorted by date ASC |
||
| 783 | * |
||
| 784 | * @return array |
||
| 785 | */ |
||
| 786 | public function getActivePriceOptions(): array |
||
| 787 | { |
||
| 788 | $activePriceOptions = []; |
||
| 789 | if ($this->getPriceOptions()) { |
||
| 790 | $compareDate = new DateTime('today midnight'); |
||
| 791 | foreach ($this->getPriceOptions() as $priceOption) { |
||
| 792 | if ($priceOption->getValidUntil() >= $compareDate) { |
||
| 793 | $activePriceOptions[$priceOption->getValidUntil()->getTimestamp()] = $priceOption; |
||
| 794 | } |
||
| 795 | } |
||
| 796 | } |
||
| 797 | ksort($activePriceOptions); |
||
| 798 | |||
| 799 | return $activePriceOptions; |
||
| 800 | } |
||
| 801 | |||
| 802 | /** |
||
| 803 | * Returns the current price of the event respecting possible price options |
||
| 804 | * |
||
| 805 | * @return float |
||
| 806 | */ |
||
| 807 | public function getCurrentPrice(): float |
||
| 808 | { |
||
| 809 | $activePriceOptions = $this->getActivePriceOptions(); |
||
| 810 | if (count($activePriceOptions) >= 1) { |
||
| 811 | // Sort active price options and return first element |
||
| 812 | return reset($activePriceOptions)->getPrice(); |
||
| 813 | } |
||
| 814 | // Just return the price field |
||
| 815 | return $this->price; |
||
| 816 | } |
||
| 817 | |||
| 818 | public function getRegistrationWaitlist(): ?ObjectStorage |
||
| 819 | { |
||
| 820 | return $this->registrationWaitlist; |
||
| 821 | } |
||
| 822 | |||
| 823 | public function setRegistrationWaitlist(?ObjectStorage $registration): void |
||
| 824 | { |
||
| 825 | $this->registrationWaitlist = $registration; |
||
| 826 | } |
||
| 827 | |||
| 828 | public function addRegistrationWaitlist(Registration $registration): void |
||
| 829 | { |
||
| 830 | $this->registrationWaitlist->attach($registration); |
||
| 831 | } |
||
| 832 | |||
| 833 | public function removeRegistrationWaitlist(Registration $registrationToRemove): void |
||
| 834 | { |
||
| 835 | $this->registrationWaitlist->detach($registrationToRemove); |
||
| 836 | } |
||
| 837 | |||
| 838 | /** |
||
| 839 | * Returns, if cancellation for registrations of the event is possible |
||
| 840 | * |
||
| 841 | * @return bool |
||
| 842 | */ |
||
| 843 | public function getCancellationPossible(): bool |
||
| 844 | { |
||
| 845 | $today = new DateTime('today'); |
||
| 846 | |||
| 847 | return ($this->getEnableCancel() && $this->getCancelDeadline() > $today) || |
||
| 848 | ($this->getEnableCancel() && $this->getCancelDeadline() === null && $this->getStartdate() > $today); |
||
| 849 | } |
||
| 850 | |||
| 851 | public function getSpeaker(): ?ObjectStorage |
||
| 852 | { |
||
| 853 | return $this->speaker; |
||
| 854 | } |
||
| 855 | |||
| 856 | public function setSpeaker(?ObjectStorage $speaker): void |
||
| 857 | { |
||
| 858 | $this->speaker = $speaker; |
||
| 859 | } |
||
| 860 | |||
| 861 | public function addSpeaker(Speaker $speaker): void |
||
| 862 | { |
||
| 863 | $this->speaker->attach($speaker); |
||
| 864 | } |
||
| 865 | |||
| 866 | public function removeSpeaker(Speaker $speaker): void |
||
| 867 | { |
||
| 868 | $this->speaker->detach($speaker); |
||
| 869 | } |
||
| 870 | |||
| 871 | public function getRegistrationFields(): ?ObjectStorage |
||
| 872 | { |
||
| 873 | return $this->registrationFields; |
||
| 874 | } |
||
| 875 | |||
| 876 | public function setRegistrationFields(?ObjectStorage $registrationFields): void |
||
| 877 | { |
||
| 878 | $this->registrationFields = $registrationFields; |
||
| 879 | } |
||
| 880 | |||
| 881 | public function addRegistrationFields(Field $registrationField): void |
||
| 884 | } |
||
| 885 | |||
| 886 | public function removeRegistrationFields(Field $registrationField): void |
||
| 887 | { |
||
| 888 | $this->registrationFields->detach($registrationField); |
||
| 889 | } |
||
| 890 | |||
| 891 | public function getRegistrationFieldsUids(): array |
||
| 892 | { |
||
| 893 | $result = []; |
||
| 894 | foreach ($this->registrationFields as $registrationField) { |
||
| 895 | $result[] = $registrationField->getUid(); |
||
| 896 | } |
||
| 897 | |||
| 898 | return $result; |
||
| 899 | } |
||
| 900 | |||
| 901 | /** |
||
| 902 | * Returns an array with registration field uids and titles |
||
| 903 | * [uid => title] |
||
| 904 | * |
||
| 905 | * @return array |
||
| 906 | */ |
||
| 907 | public function getRegistrationFieldUidsWithTitle(): array |
||
| 908 | { |
||
| 909 | $result = []; |
||
| 910 | foreach ($this->registrationFields as $registrationField) { |
||
| 911 | $result[$registrationField->getUid()] = $registrationField->getTitle(); |
||
| 912 | } |
||
| 913 | |||
| 914 | return $result; |
||
| 915 | } |
||
| 916 | |||
| 917 | /** |
||
| 918 | * Special getter to return the amount of registrations that are saved to default language |
||
| 919 | * Required since TYPO3 9.5 (#82363) |
||
| 920 | * |
||
| 921 | * @return ObjectStorage |
||
| 922 | */ |
||
| 923 | public function getRegistrations(): ?ObjectStorage |
||
| 924 | { |
||
| 925 | $languageAspect = GeneralUtility::makeInstance(Context::class)->getAspect('language'); |
||
| 926 | if ($languageAspect->getId() > 0) { |
||
| 927 | return $this->getRegistrationsDefaultLanguage(false); |
||
| 928 | } |
||
| 929 | |||
| 930 | return $this->registration; |
||
| 931 | } |
||
| 932 | |||
| 933 | /** |
||
| 934 | * Special getter to return the amount of waitlist registrations that are saved to default language |
||
| 935 | * Required since TYPO3 9.5 (#82363) |
||
| 936 | * |
||
| 937 | * @return ObjectStorage |
||
| 938 | */ |
||
| 939 | public function getRegistrationsWaitlist(): ?ObjectStorage |
||
| 940 | { |
||
| 941 | $languageAspect = GeneralUtility::makeInstance(Context::class)->getAspect('language'); |
||
| 942 | if ($languageAspect->getId() > 0) { |
||
| 943 | return $this->getRegistrationsDefaultLanguage(true); |
||
| 944 | } |
||
| 945 | |||
| 946 | return $this->registrationWaitlist; |
||
| 947 | } |
||
| 948 | |||
| 949 | /** |
||
| 950 | * Returns an objectStorage object holding all registrations in the default language. |
||
| 951 | * Ensures expected behavior of getRegistration() and getRegistrationWaitlist() since TYPO3 issue #82363 |
||
| 952 | * |
||
| 953 | * @param bool $waitlist |
||
| 954 | * @return ObjectStorage |
||
| 955 | */ |
||
| 956 | protected function getRegistrationsDefaultLanguage(bool $waitlist = false): ObjectStorage |
||
| 957 | { |
||
| 958 | $result = GeneralUtility::makeInstance(ObjectStorage::class); |
||
| 959 | $registrationRepository = GeneralUtility::makeInstance(RegistrationRepository::class); |
||
| 960 | $registrations = $registrationRepository->findByEventAndWaitlist($this, $waitlist); |
||
| 961 | foreach ($registrations as $registration) { |
||
| 962 | $result->attach($registration); |
||
| 963 | } |
||
| 964 | |||
| 965 | return $result; |
||
| 966 | } |
||
| 967 | |||
| 968 | public function getEndsSameDay(): bool |
||
| 975 | } |
||
| 976 | |||
| 977 | public function getSpamCheckChallenge(): string |
||
| 978 | { |
||
| 979 | return MiscUtility::getSpamCheckChallenge($this->getUid()); |
||
| 980 | } |
||
| 981 | |||
| 982 | /** |
||
| 983 | * Returns a string to be used as overlay value for the <core:icon> ViewHelper in the Backend Modules |
||
| 984 | * |
||
| 985 | * @return string |
||
| 986 | */ |
||
| 987 | public function getBackendIconOverlay(): string |
||
| 1002 | } |
||
| 1003 | |||
| 1004 | public function getIsStarted(): bool |
||
| 1005 | { |
||
| 1006 | return $this->startdate !== null && $this->startdate < new \DateTime(); |
||
| 1007 | } |
||
| 1008 | |||
| 1009 | public function getIsEnded(): bool |
||
| 1010 | { |
||
| 1011 | return $this->enddate !== null && $this->enddate < new \DateTime(); |
||
| 1012 | } |
||
| 1013 | |||
| 1014 | public function getIsInProgress(): bool |
||
| 1015 | { |
||
| 1016 | return $this->startdate !== null && $this->enddate !== null |
||
| 1017 | && $this->startdate < new \DateTime() |
||
| 1018 | && $this->enddate > new \DateTime(); |
||
| 1019 | } |
||
| 1020 | } |
||
| 1021 |
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