/** * Duplicates (all public accessable properties) the given registration the * amount of times configured in amountOfRegistrations * * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration Registration * * @return void */ public function createDependingRegistrations($registration) { $registrations = $registration->getAmountOfRegistrations(); for ($i = 1; $i <= $registrations - 1; $i++) { /** @var \DERHANSEN\SfEventMgt\Domain\Model\Registration $newReg */ $newReg = $this->objectManager->get('DERHANSEN\\SfEventMgt\\Domain\\Model\\Registration'); $properties = ObjectAccess::getGettableProperties($registration); foreach ($properties as $propertyName => $propertyValue) { ObjectAccess::setProperty($newReg, $propertyName, $propertyValue); } $newReg->setMainRegistration($registration); $newReg->setAmountOfRegistrations(1); $newReg->setIgnoreNotifications(TRUE); $this->registrationRepository->add($newReg); } }
/** * Checks, if the registration can successfully be created. Note, that * $result is passed by reference! * * @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration Registration * @param RegistrationResult $result Result * * @return bool */ public function checkRegistrationSuccess($event, $registration, &$result) { $success = true; if ($event->getEnableRegistration() === false) { $success = false; $result = RegistrationResult::REGISTRATION_NOT_ENABLED; } elseif ($event->getRegistrationDeadline() != null && $event->getRegistrationDeadline() < new \DateTime()) { $success = false; $result = RegistrationResult::REGISTRATION_FAILED_DEADLINE_EXPIRED; } elseif ($event->getStartdate() < new \DateTime()) { $success = false; $result = RegistrationResult::REGISTRATION_FAILED_EVENT_EXPIRED; } elseif ($event->getRegistration()->count() >= $event->getMaxParticipants() && $event->getMaxParticipants() > 0 && !$event->getEnableWaitlist()) { $success = false; $result = RegistrationResult::REGISTRATION_FAILED_MAX_PARTICIPANTS; } elseif ($event->getFreePlaces() < $registration->getAmountOfRegistrations() && $event->getMaxParticipants() > 0 && !$event->getEnableWaitlist()) { $success = false; $result = RegistrationResult::REGISTRATION_FAILED_NOT_ENOUGH_FREE_PLACES; } elseif ($event->getMaxRegistrationsPerUser() < $registration->getAmountOfRegistrations()) { $success = false; $result = RegistrationResult::REGISTRATION_FAILED_MAX_AMOUNT_REGISTRATIONS_EXCEEDED; } elseif ($event->getUniqueEmailCheck() && $this->emailNotUnique($event, $registration->getEmail())) { $success = false; $result = RegistrationResult::REGISTRATION_FAILED_EMAIL_NOT_UNIQUE; } elseif ($event->getRegistration()->count() >= $event->getMaxParticipants() && $event->getMaxParticipants() > 0 && $event->getEnableWaitlist()) { $result = RegistrationResult::REGISTRATION_SUCCESSFUL_WAITLIST; } return $success; }
/** * Checks, if the registration can successfully be created. Note, that * $result is passed by reference! * * @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration Registration * @param RegistrationResult $result Result * * @return bool */ protected function checkRegistrationSuccess(Event $event, Registration $registration, &$result) { $success = TRUE; if ($event->getEnableRegistration() === FALSE) { $success = FALSE; $result = RegistrationResult::REGISTRATION_NOT_ENABLED; } elseif ($event->getRegistrationDeadline() != NULL && $event->getRegistrationDeadline() < new \DateTime()) { $success = FALSE; $result = RegistrationResult::REGISTRATION_FAILED_DEADLINE_EXPIRED; } elseif ($event->getStartdate() < new \DateTime()) { $success = FALSE; $result = RegistrationResult::REGISTRATION_FAILED_EVENT_EXPIRED; } elseif ($event->getRegistration()->count() >= $event->getMaxParticipants() && $event->getMaxParticipants() > 0) { $success = FALSE; $result = RegistrationResult::REGISTRATION_FAILED_MAX_PARTICIPANTS; } elseif ($event->getFreePlaces() < $registration->getAmountOfRegistrations() && $event->getMaxParticipants() > 0) { $success = FALSE; $result = RegistrationResult::REGISTRATION_FAILED_NOT_ENOUGH_FREE_PLACES; } elseif ($event->getMaxRegistrationsPerUser() < $registration->getAmountOfRegistrations()) { $success = FALSE; $result = RegistrationResult::REGISTRATION_FAILED_MAX_AMOUNT_REGISTRATIONS_EXCEEDED; } return $success; }
/** * @test * @return void */ public function amountOfRegistrationSetsAmountOfRegistrations() { $this->subject->setAmountOfRegistrations(2); $this->assertEquals(2, $this->subject->getAmountOfRegistrations()); }