/** * @test */ public function cancelDependingRegistrationsRemovesDependingRegistrations() { $mockRegistration = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Model\\Registration', array(), array(), '', FALSE); $foundRegistration1 = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Model\\Registration', array(), array(), '', FALSE); $foundRegistration2 = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Model\\Registration', array(), array(), '', FALSE); /** @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage $registrations */ $registrations = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage(); $registrations->attach($foundRegistration1); $registrations->attach($foundRegistration2); $registrationRepository = $this->getMock('DERHANSEN\\SfEventMgt\\Domain\\Repository\\RegistrationRepository', array('findByMainRegistration', 'remove'), array(), '', FALSE); $registrationRepository->expects($this->once())->method('findByMainRegistration')->will($this->returnValue($registrations)); $registrationRepository->expects($this->exactly(2))->method('remove'); $this->inject($this->subject, 'registrationRepository', $registrationRepository); $this->subject->cancelDependingRegistrations($mockRegistration); }
/** * @param \DERHANSEN\SfEventMgt\Domain\Model\Registration $registration * @param string $hmac */ public function cancelAction($registration, $hmac) { $this->validateHmacForAction($registration, $hmac, $this->actionMethodName); $this->proceedWithAction($registration, $this->actionMethodName); $values = ['html' => '']; $paymentMethod = $registration->getPaymentmethod(); /** * Update- and remove flags */ $updateRegistration = false; $removeRegistration = false; $this->signalSlotDispatcher->dispatch(__CLASS__, __FUNCTION__ . 'ProcessCancel' . ucfirst($paymentMethod), [&$values, &$updateRegistration, &$removeRegistration, $registration, GeneralUtility::_GET(), $this]); if ($updateRegistration) { $this->registrationRepository->update($registration); } if ($removeRegistration) { // First cancel depending registrations if ($registration->getAmountOfRegistrations() > 1) { $this->registrationService->cancelDependingRegistrations($registration); } $this->registrationRepository->remove($registration); } $this->view->assign('result', $values); }
/** * Cancels the registration if possible and sends e-mails to admin and user * * @param int $reguid UID of registration * @param string $hmac HMAC for parameters * * @return void */ public function cancelRegistrationAction($reguid, $hmac) { /* @var $registration Registration */ list($failed, $registration, $messageKey, $titleKey) = $this->registrationService->checkCancelRegistration($reguid, $hmac); if ($failed === false) { // Send notifications (must run before cancelling the registration) $this->notificationService->sendUserMessage($registration->getEvent(), $registration, $this->settings, MessageType::REGISTRATION_CANCELLED); $this->notificationService->sendAdminMessage($registration->getEvent(), $registration, $this->settings, MessageType::REGISTRATION_CANCELLED); // First cancel depending registrations if ($registration->getAmountOfRegistrations() > 1) { $this->registrationService->cancelDependingRegistrations($registration); } // Finally cancel registration $this->registrationRepository->remove($registration); // Clear cache for configured pages $this->utilityService->clearCacheForConfiguredUids($this->settings); } $this->view->assign('messageKey', $messageKey); $this->view->assign('titleKey', $titleKey); }