Skip to content

Commit

Permalink
TASK: sendActivationLetter async
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaip committed Jan 27, 2017
1 parent 74e7f95 commit 89690ae
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 25 deletions.
15 changes: 1 addition & 14 deletions Classes/Psmb/Newsletter/Controller/SubscriptionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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');
}
}
Expand Down Expand Up @@ -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);
}

}
16 changes: 6 additions & 10 deletions Classes/Psmb/Newsletter/Service/FusionMailService.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,6 @@ class FusionMailService {
*/
protected $globalSettings;

/**
* @Flow\Inject
* @var SubscriberRepository
*/
protected $subscriberRepository;

/**
* @Flow\InjectConfiguration(package="TYPO3.Flow", path="http.baseUri")
* @var string
Expand Down Expand Up @@ -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']);
Expand All @@ -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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Configuration/Routes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
appendExceedingArguments: TRUE

-
name: 'Psmb.Newsletter send action'
name: 'Psmb.Newsletter AJAX routes'
uriPattern: 'newsletter/{@action}'
defaults:
'@package': 'Psmb.Newsletter'
Expand Down

0 comments on commit 89690ae

Please sign in to comment.