/**
  * 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);
     }
 }
 /**
  * Saves the registration
  *
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration Registration
  * @param \DERHANSEN\SfEventMgt\Domain\Model\Event $event Event
  * @validate $registration \DERHANSEN\SfEventMgt\Validation\Validator\RegistrationValidator
  *
  * @return void
  */
 public function saveRegistrationAction(Registration $registration, Event $event)
 {
     $autoConfirmation = (bool) $this->settings['registration']['autoConfirmation'];
     $result = RegistrationResult::REGISTRATION_SUCCESSFUL;
     $success = $this->registrationService->checkRegistrationSuccess($event, $registration, $result);
     // Save registration if no errors
     if ($success) {
         $isWaitlistRegistration = $this->registrationService->isWaitlistRegistration($event, $registration->getAmountOfRegistrations());
         $linkValidity = (int) $this->settings['confirmation']['linkValidity'];
         if ($linkValidity === 0) {
             // Use 3600 seconds as default value if not set
             $linkValidity = 3600;
         }
         $confirmationUntil = new \DateTime();
         $confirmationUntil->add(new \DateInterval('PT' . $linkValidity . 'S'));
         $registration->setEvent($event);
         $registration->setPid($event->getPid());
         $registration->setConfirmationUntil($confirmationUntil);
         $registration->setLanguage($GLOBALS['TSFE']->config['config']['language']);
         $registration->setFeUser($this->registrationService->getCurrentFeUserObject());
         $registration->setWaitlist($isWaitlistRegistration);
         $registration->_setProperty('_languageUid', $GLOBALS['TSFE']->sys_language_uid);
         $this->registrationRepository->add($registration);
         // Persist registration, so we have an UID
         $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager')->persistAll();
         // Add new registration (or waitlist registration) to event
         if ($isWaitlistRegistration) {
             $event->addRegistrationWaitlist($registration);
             $messageType = MessageType::REGISTRATION_WAITLIST_NEW;
         } else {
             $event->addRegistration($registration);
             $messageType = MessageType::REGISTRATION_NEW;
         }
         $this->eventRepository->update($event);
         // Send notifications to user and admin if confirmation link should be sent
         if (!$autoConfirmation) {
             $this->notificationService->sendUserMessage($event, $registration, $this->settings, $messageType);
             $this->notificationService->sendAdminMessage($event, $registration, $this->settings, $messageType);
         }
         // Create given amount of registrations if necessary
         if ($registration->getAmountOfRegistrations() > 1) {
             $this->registrationService->createDependingRegistrations($registration);
         }
         // Clear cache for configured pages
         $this->utilityService->clearCacheForConfiguredUids($this->settings);
     }
     if ($autoConfirmation && $success) {
         $this->redirect('confirmRegistration', null, null, ['reguid' => $registration->getUid(), 'hmac' => $this->hashService->generateHmac('reg-' . $registration->getUid())]);
     } else {
         $this->redirect('saveRegistrationResult', null, null, ['result' => $result]);
     }
 }