Skip to content

Commit

Permalink
Merge pull request #26 from GFEMediaGmbH/redirect-finisher
Browse files Browse the repository at this point in the history
Add RedirectFinisher that performs redirect with JSON response
  • Loading branch information
lukaszuznanski authored Jun 5, 2023
2 parents e6f3e17 + 4b46cf8 commit 76ccfba
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
29 changes: 29 additions & 0 deletions Classes/Finisher/RedirectFinisher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

declare(strict_types=1);
namespace FriendsOfTYPO3\HeadlessPowermail\Finisher;

use In2code\Powermail\Domain\Service\RedirectUriService;
use In2code\Powermail\Utility\FrontendUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;

class RedirectFinisher extends \In2code\Powermail\Finisher\RedirectFinisher
{
/**
* Redirect user after form submit
*
* @return void
*/
public function redirectToUriFinisher(): void
{
$redirectService = GeneralUtility::makeInstance(RedirectUriService::class, $this->contentObject);
$uri = $redirectService->getRedirectUri();
if (!empty($uri) && $this->isRedirectEnabled()) {
echo json_encode([
'redirectUrl' => $uri,
'statusCode' => 303,
]);
die;
}
}
}
11 changes: 11 additions & 0 deletions Configuration/TypoScript/setup.typoscript
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
plugin.tx_powermail {
settings {
setup {
finishers {
# Override powermail's RedirectFinisher
100.class = FriendsOfTYPO3\HeadlessPowermail\Finisher\RedirectFinisher
}
}
}
}

tt_content.list =< lib.contentElementWithHeader
tt_content.list {
fields {
Expand Down

0 comments on commit 76ccfba

Please sign in to comment.