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