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',
|
||||
|
||||
Reference in new issue
Block a user