-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BUGFIX] Model redirects in Extbase actions as proper responses
- Loading branch information
1 parent
b44597c
commit ff24911
Showing
3 changed files
with
55 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OliverKlee\Seminars\Controller; | ||
|
||
use Psr\Http\Message\ResponseInterface; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; | ||
|
||
/** | ||
* This convenience trait provides a method to redirect to a different action that is also compatible | ||
* with TYPO3 12LTS and 13LTS. | ||
* | ||
* @phpstan-require-extends ActionController | ||
* | ||
* @internal | ||
*/ | ||
trait RedirectTrait | ||
{ | ||
/** | ||
* @param array<string, string|int> $arguments | ||
*/ | ||
private function buildRedirectToAction( | ||
string $actionName, | ||
?string $controllerName = null, | ||
?string $extensionName = null, | ||
array $arguments = [], | ||
?int $pageUid = null | ||
): ResponseInterface { | ||
if ($controllerName === null) { | ||
$controllerName = $this->request->getControllerName(); | ||
} | ||
$this->uriBuilder->reset()->setCreateAbsoluteUri(true); | ||
if (\is_int($pageUid)) { | ||
$this->uriBuilder->setTargetPageUid($pageUid); | ||
} | ||
if (GeneralUtility::getIndpEnv('TYPO3_SSL')) { | ||
$this->uriBuilder->setAbsoluteUriScheme('https'); | ||
} | ||
$uri = $this->uriBuilder->uriFor($actionName, $arguments, $controllerName, $extensionName); | ||
|
||
return $this->responseFactory->createResponse(307)->withHeader('Location', $uri); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters