Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RedirectFinisher that performs redirect with JSON response #26

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
lukaszuznanski marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
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