feat: bring back the newsletter subscription plugin
The "Newsletter-/RA-Registrierung" plugin (epproducts_newsletter_subscription) subscribes to the Mailjet lists through the MyE&P API and is still in use on the newsletter, travel alert and travel for groups pages; retiring it in49b96dfwas a mistake. Controller and templates come back froma46918d, ported to TYPO3 13 (actions return responses). The DTO and the API client calls were still in place. The "newsletter" result message plugin (index action) is not part of this. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
b794257f61
commit
de3bbbe2f5
6 files changed
+225
-2
No files matched your search
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpProducts\Controller;
|
||||
|
||||
/***************************************************************
|
||||
*
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2016 Björn Fromme <[email protected]>, dreipunktnull
|
||||
*
|
||||
* All rights reserved
|
||||
*
|
||||
* This script is part of the TYPO3 project. The TYPO3 project is
|
||||
* free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* The GNU General Public License can be found at
|
||||
* http://www.gnu.org/copyleft/gpl.html.
|
||||
*
|
||||
* This script is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
***************************************************************/
|
||||
|
||||
use EP\EpProducts\Domain\Model\Dto\NewsletterSubscriptionRequest;
|
||||
use EP\EpProducts\MyEP\ApiClient;
|
||||
use EP\EpProducts\MyEP\ApiException;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
|
||||
|
||||
class NewsletterController extends ActionController
|
||||
{
|
||||
private ApiClient $apiClient;
|
||||
|
||||
public function __construct(ApiClient $apiClient)
|
||||
{
|
||||
$this->apiClient = $apiClient;
|
||||
}
|
||||
|
||||
public function subscriptionFormAction(?NewsletterSubscriptionRequest $subscriptionRequest = null): ResponseInterface
|
||||
{
|
||||
if (null === $subscriptionRequest) {
|
||||
$subscriptionRequest = new NewsletterSubscriptionRequest();
|
||||
}
|
||||
|
||||
try {
|
||||
$lists = $this->apiClient->getNewsletterLists();
|
||||
} catch (ApiException $e) {
|
||||
$lists = [];
|
||||
}
|
||||
|
||||
$this->view->assign('subscriptionRequest', $subscriptionRequest);
|
||||
$this->view->assign('lists', $lists);
|
||||
|
||||
return $this->htmlResponse();
|
||||
}
|
||||
|
||||
public function subscriptionFormSubmitAction(NewsletterSubscriptionRequest $subscriptionRequest): ResponseInterface
|
||||
{
|
||||
try {
|
||||
$result = $this->apiClient->subscribeToNewsletters($subscriptionRequest);
|
||||
$result['success'] = true;
|
||||
} catch (ApiException $e) {
|
||||
$result = [
|
||||
'success' => false,
|
||||
'message' => $e->getMessage(),
|
||||
];
|
||||
}
|
||||
|
||||
$this->view->assign('result', $result);
|
||||
|
||||
return $this->htmlResponse();
|
||||
}
|
||||
}
|
||||
@@ -127,6 +127,12 @@ call_user_func(function () {
|
||||
'FAQ'
|
||||
);
|
||||
|
||||
ExtensionUtility::registerPlugin(
|
||||
'EpProducts',
|
||||
'newsletter_subscription',
|
||||
'Newsletter-/RA-Registrierung'
|
||||
);
|
||||
|
||||
ExtensionUtility::registerPlugin(
|
||||
'EpProducts',
|
||||
'maps',
|
||||
|
||||
@@ -7,6 +7,7 @@ use EP\EpProducts\Controller\CountryController;
|
||||
use EP\EpProducts\Controller\FaqController;
|
||||
use EP\EpProducts\Controller\HotelController;
|
||||
use EP\EpProducts\Controller\MapController;
|
||||
use EP\EpProducts\Controller\NewsletterController;
|
||||
use EP\EpProducts\Controller\PricetableController;
|
||||
use EP\EpProducts\Controller\RegionController;
|
||||
use EP\EpProducts\Controller\TeamController;
|
||||
@@ -174,6 +175,17 @@ $boot = function () {
|
||||
]
|
||||
);
|
||||
|
||||
ExtensionUtility::configurePlugin(
|
||||
'EpProducts',
|
||||
'newsletter_subscription',
|
||||
[
|
||||
NewsletterController::class => 'subscriptionForm,subscriptionFormSubmit',
|
||||
],
|
||||
[
|
||||
NewsletterController::class => 'subscriptionForm,subscriptionFormSubmit',
|
||||
]
|
||||
);
|
||||
|
||||
ExtensionUtility::configurePlugin(
|
||||
'EpProducts',
|
||||
'maps',
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Retired 2026-10-24 (newsletter form and subscription, reseller export, group price calculator, which
|
||||
# Retired 2026-10-24 (newsletter form, reseller export, group price calculator, which
|
||||
# MyE&P replaced): the elements stay in the database and render nothing; the old code is in a46918d
|
||||
# should they come back
|
||||
tt_content.nlform = TEXT
|
||||
tt_content.list.20.epproducts_newsletter_subscription = TEXT
|
||||
tt_content.list.20.epproducts_reseller = TEXT
|
||||
tt_content.list.20.epproducts_hotel_groups_price = TEXT
|
||||
@@ -0,0 +1,104 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
|
||||
xmlns:f="http://typo3.org/ns/fluid/ViewHelpers">
|
||||
|
||||
<f:layout name="Default"/>
|
||||
|
||||
<f:section name="Main">
|
||||
<a id="newsletter-form" class="anchor"></a>
|
||||
<div class="container">
|
||||
<f:form method="post" action="subscriptionFormSubmit" name="subscriptionRequest" section="newsletter-form" object="{subscriptionRequest}">
|
||||
<div class="grid lg:grid-cols-2 lg:gap-x-8 items-start">
|
||||
<div>
|
||||
<f:render section="Field" arguments="{property: 'firstName', label: 'Vorname'}"/>
|
||||
<f:render section="Field" arguments="{property: 'lastName', label: 'Nachname'}"/>
|
||||
<f:render section="Field" arguments="{property: 'email', label: 'E-Mail'}"/>
|
||||
<div class="mb-4">
|
||||
<f:form.validationResults for="subscriptionRequest.consent">
|
||||
<label class="inline-flex items-center">
|
||||
<f:form.checkbox property="consent" value="1" class="form-checkbox{f:if(condition: validationResults.errors.0, then: ' form-checkbox--has-error')}"/>
|
||||
<span class="block ml-2">Ich akzeptiere die <f:link.typolink parameter="{settings.dataProtectionPageUid}" class="underline" target="_blank">Datenschutzbestimmungen</f:link.typolink>*</span>
|
||||
</label>
|
||||
<f:if condition="{validationResults.flattenedErrors}">
|
||||
<div class="text-red-500 mt-2" role="alert">
|
||||
<f:for each="{validationResults.errors}" as="error">
|
||||
{f:translate(key: 'tx_eptheme.message.newsletter.consent.{error.code}', extensionName: 'ep_theme')}
|
||||
<br />
|
||||
</f:for>
|
||||
</div>
|
||||
</f:if>
|
||||
</f:form.validationResults>
|
||||
</div>
|
||||
<div class="hidden lg:block">
|
||||
<button type="submit" class="button bg-button">
|
||||
Anmelden
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div>
|
||||
<f:form.validationResults for="subscriptionRequest.listIds">
|
||||
<f:for each="{lists}" as="list" iteration="iteration">
|
||||
<f:comment><!-- show different headline for first newsletter in list --></f:comment>
|
||||
<f:if condition="{iteration.isFirst}">
|
||||
<f:then>
|
||||
<h3>
|
||||
News & Angebote per Mail
|
||||
</h3>
|
||||
</f:then>
|
||||
<f:else>
|
||||
<f:comment><!-- show headline only once --></f:comment>
|
||||
<f:if condition="{alertHeadline}">
|
||||
<f:else>
|
||||
<f:variable name="alertHeadline" value="1"/>
|
||||
<h3 class="pt-4">
|
||||
Benachrichtige mich bei Verfügbarkeit
|
||||
</h3>
|
||||
</f:else>
|
||||
</f:if>
|
||||
</f:else>
|
||||
</f:if>
|
||||
<label for="list-{list.id}" class="flex items-center">
|
||||
<f:form.checkbox property="listIds" multiple="1" value="{list.id}" class="form-checkbox"/>
|
||||
<span class="block ml-2">{list.label}</span>
|
||||
</label>
|
||||
</f:for>
|
||||
<f:if condition="{validationResults.flattenedErrors}">
|
||||
<div class="text-red-500 mt-2" role="alert">
|
||||
<f:for each="{validationResults.errors}" as="error">
|
||||
{f:translate(key: 'tx_eptheme.message.newsletter.listIds.{error.code}', extensionName: 'ep_theme')}
|
||||
<br />
|
||||
</f:for>
|
||||
</div>
|
||||
</f:if>
|
||||
</f:form.validationResults>
|
||||
</div>
|
||||
</div>
|
||||
<div class="lg:hidden mt-4">
|
||||
<button type="submit" class="button bg-button">
|
||||
Anmelden
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</f:form>
|
||||
</div>
|
||||
</f:section>
|
||||
|
||||
<f:section name="Field">
|
||||
<f:form.validationResults for="subscriptionRequest.{property}">
|
||||
<f:variable name="hasErrors" value="{validationResults.errors.0}"/>
|
||||
<label class="block mb-4">
|
||||
<span class="{f:if(condition: hasErrors, then: 'text-red-500', else: 'text-zinc-700')}">{label}*</span>
|
||||
<f:form.textfield property="{property}" class="form-field {f:if(condition: hasErrors, then: 'form-field--has-error')}"/>
|
||||
<f:if condition="{validationResults.flattenedErrors}">
|
||||
<div class="text-red-500 mt-2" role="alert">
|
||||
<f:for each="{validationResults.errors}" as="error">
|
||||
{f:translate(key: 'tx_eptheme.message.contactForm.{property}.{error.code}', extensionName: 'ep_theme')}
|
||||
<br />
|
||||
</f:for>
|
||||
</div>
|
||||
</f:if>
|
||||
</label>
|
||||
</f:form.validationResults>
|
||||
</f:section>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,23 @@
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"
|
||||
xmlns:f="http://typo3.org/ns/fluid/ViewHelpers">
|
||||
|
||||
<f:layout name="Default"/>
|
||||
|
||||
<f:section name="Main">
|
||||
<div class="container">
|
||||
<div class="bg-ep-primary-light text-white p-4">
|
||||
<h2>
|
||||
Vielen Dank für dein Interesse
|
||||
</h2>
|
||||
<p>
|
||||
Deine Anmeldung muss noch bestätigt werden. Bitte nutze den Link aus der Bestätigungs-E-Mail, die in
|
||||
Kürze bei dir eintreffen sollte.
|
||||
</p>
|
||||
<p class="text-sm">
|
||||
Sieh am besten auch im Spam-Ordner nach.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</f:section>
|
||||
|
||||
</html>
|
||||
Reference in new issue
Block a user