コード例 #1
0
 /**
  * @test
  */
 public function createDependingRegistrationsCreatesAmountOfExpectedRegistrations()
 {
     $mockRegistration = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Model\\Registration', array(), array(), '', FALSE);
     $mockRegistration->expects($this->any())->method('getAmountOfRegistrations')->will($this->returnValue(5));
     $newRegistration = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Model\\Registration', array(), array(), '', FALSE);
     $newRegistration->expects($this->any())->method('setMainRegistration');
     $newRegistration->expects($this->any())->method('setAmountOfRegistrations');
     $newRegistration->expects($this->any())->method('setIgnoreNotifications');
     $objectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManager', array(), array(), '', FALSE);
     $objectManager->expects($this->any())->method('get')->will($this->returnValue($newRegistration));
     $this->inject($this->subject, 'objectManager', $objectManager);
     $registrationRepository = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Repository\\RegistrationRepository', array('add'), array(), '', FALSE);
     $registrationRepository->expects($this->exactly(4))->method('add')->with($newRegistration);
     $this->inject($this->subject, 'registrationRepository', $registrationRepository);
     $this->subject->createDependingRegistrations($mockRegistration);
 }
コード例 #2
0
 /**
  * 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]);
     }
 }