From 89690aecf48d32ca7f329fa67f80e3f39388cf8f Mon Sep 17 00:00:00 2001 From: Dmitri Pisarev Date: Fri, 27 Jan 2017 12:14:30 +0300 Subject: [PATCH] TASK: sendActivationLetter async --- .../Controller/SubscriptionController.php | 15 +-------------- .../Newsletter/Service/FusionMailService.php | 16 ++++++---------- Configuration/Routes.yaml | 2 +- 3 files changed, 8 insertions(+), 25 deletions(-) diff --git a/Classes/Psmb/Newsletter/Controller/SubscriptionController.php b/Classes/Psmb/Newsletter/Controller/SubscriptionController.php index 9e1fb63..9791b7d 100644 --- a/Classes/Psmb/Newsletter/Controller/SubscriptionController.php +++ b/Classes/Psmb/Newsletter/Controller/SubscriptionController.php @@ -68,7 +68,6 @@ public function indexAction() */ public function registerAction(Subscriber $subscriber) { - $email = $subscriber->getEmail(); if (!$email) { $message = $this->translator->translateById('flash.noEmail', [], null, null, 'Main', 'Psmb.Newsletter'); @@ -97,7 +96,7 @@ public function registerAction(Subscriber $subscriber) ); $message = $this->translator->translateById('flash.confirm', [], null, null, 'Main', 'Psmb.Newsletter'); $this->addFlashMessage($message); - $this->sendActivationLetter($subscriber, $hash); + $this->fusionMailService->sendActivationLetter($subscriber, $hash); $this->redirect('feedback'); } } @@ -174,16 +173,4 @@ public function feedbackAction() { } - /** - * Sends an activation mail - * - * @param Subscriber $subscriber - * @param string $hash - * @return void - */ - protected function sendActivationLetter(Subscriber $subscriber, $hash) { - $activationLetter = $this->fusionMailService->generateActivationLetter($subscriber, $hash); - $this->fusionMailService->sendLetter($activationLetter); - } - } diff --git a/Classes/Psmb/Newsletter/Service/FusionMailService.php b/Classes/Psmb/Newsletter/Service/FusionMailService.php index d9162d1..0b1359e 100644 --- a/Classes/Psmb/Newsletter/Service/FusionMailService.php +++ b/Classes/Psmb/Newsletter/Service/FusionMailService.php @@ -48,12 +48,6 @@ class FusionMailService { */ protected $globalSettings; - /** - * @Flow\Inject - * @var SubscriberRepository - */ - protected $subscriberRepository; - /** * @Flow\InjectConfiguration(package="TYPO3.Flow", path="http.baseUri") * @var string @@ -162,13 +156,14 @@ public function sendLetter($letter) } /** - * Generate activation letter to confirm the new subscriber + * Send activation letter to confirm the new subscriber * + * @Job\Defer(queueName="psmb-newsletter") * @param Subscriber $subscriber * @param string $hash - * @return array + * @return void */ - public function generateActivationLetter(Subscriber $subscriber, $hash) + public function sendActivationLetter(Subscriber $subscriber, $hash) { $metadata = $subscriber->getMetadata(); $siteNode = $this->getSiteNode($metadata['registrationDimensions']); @@ -189,7 +184,8 @@ public function generateActivationLetter(Subscriber $subscriber, $hash) 'globalSettings' => $this->globalSettings, 'activationLink' => $activationLink ]); - return $this->view->render(); + $letter = $this->view->render(); + $this->sendLetter($letter); } /** diff --git a/Configuration/Routes.yaml b/Configuration/Routes.yaml index 775ea77..a2b4f12 100644 --- a/Configuration/Routes.yaml +++ b/Configuration/Routes.yaml @@ -66,7 +66,7 @@ appendExceedingArguments: TRUE - - name: 'Psmb.Newsletter send action' + name: 'Psmb.Newsletter AJAX routes' uriPattern: 'newsletter/{@action}' defaults: '@package': 'Psmb.Newsletter'