Skip to content

Commit

Permalink
Support newsletter activation jumpTo forwarding also without custom n…
Browse files Browse the repository at this point in the history
…otification (see #314)
  • Loading branch information
Toflar committed Feb 29, 2024
1 parent a7dcea8 commit 8bede90
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/EventListener/Newsletter/ActivationListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,23 @@ public function __invoke(string $email, array $recipientIds, array $channelIds,
return;
}

if (!$module->nc_activation_notification) {
return;
if ($module->nc_activation_notification) {
$this->sendNotification($email, $channelIds, $module);
}

if ($module->nc_newsletter_activation_jumpTo) {
$targetPage = $this->contaoFramework->getAdapter(PageModel::class)
->findByPk($module->nc_newsletter_activation_jumpTo)
;

if ($targetPage instanceof PageModel) {
throw new RedirectResponseException($targetPage->getFrontendUrl());
}
}
}

private function sendNotification(string $email, array $channelIds, Module $module): void
{
$this->contaoFramework->initialize();

$channelModels = $this->contaoFramework->getAdapter(NewsletterChannelModel::class)
Expand All @@ -46,15 +59,5 @@ public function __invoke(string $email, array $recipientIds, array $channelIds,
$tokens['channel_ids'] = implode(', ', $channelIds);

$this->notificationCenter->sendNotification((int) $module->nc_activation_notification, $tokens);

if ($module->nc_newsletter_activation_jumpTo) {
$targetPage = $this->contaoFramework->getAdapter(PageModel::class)
->findByPk($module->nc_newsletter_activation_jumpTo)
;

if ($targetPage instanceof PageModel) {
throw new RedirectResponseException($targetPage->getFrontendUrl());
}
}
}
}

0 comments on commit 8bede90

Please sign in to comment.