/** * Shows a list of all registration of the current frontend user * * @return void */ public function listAction() { $demand = $this->createUserRegistrationDemandObjectFromSettings($this->settings); $demand->setUser($this->registrationService->getCurrentFeUserObject()); $registrations = $this->registrationRepository->findRegistrationsByUserRegistrationDemand($demand); $this->view->assign('registrations', $registrations); }
/** * Test if expected value is returned if a frontend user logged in * * @test * @return void */ public function getCurrentFeUserObjectReturnsFeUser() { $GLOBALS['TSFE'] = new \stdClass(); $GLOBALS['TSFE']->fe_user = new \stdClass(); $GLOBALS['TSFE']->fe_user->user = []; $GLOBALS['TSFE']->fe_user->user['uid'] = 1; $feUser = new \TYPO3\CMS\Extbase\Domain\Model\FrontendUser(); $mockFeUserRepository = $this->getMock('TYPO3\\CMS\\Extbase\\Domain\\Repository\\FrontendUserRepository', [], [], '', false); $mockFeUserRepository->expects($this->once())->method('findByUid')->with(1)->will($this->returnValue($feUser)); $this->inject($this->subject, 'frontendUserRepository', $mockFeUserRepository); $this->assertEquals($this->subject->getCurrentFeUserObject(), $feUser); }
/** * 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]); } }