簡體   English   中英

有沒有辦法從一個插件重定向到 Extbase 中的另一個插件?

[英]Is there a way to redirect from one plugin to another plugin in Extbase?

使用 Typo3 V11.5.15 我需要一種方法,在給定公司尚不存在時,從一個將新員工添加到列表的表單轉移到另一個表單。

我嘗試使用重定向和 URI 構建器,但似乎沒有任何效果。

我確實希望在用戶可以檢查輸入的第二頁中有 af:link.action。 我經常在舊線程中看到這個推薦。


編輯1 我確實使用AJAX使用重定向檢查了 4 年前的舊錯誤。 但這現在應該已經過時了,舊的解決方案似乎不起作用。


編輯2

我做了類似於 Stefan Bürk 的回答所暗示的事情。

//added the UriBuilder first
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;

//new instance of UriBuilder and using it to ... build the Uri....
$uriBuilder = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(UriBuilder::class);
$uriBuilder->setTargetPageUid($PageUidGoesHere);
$uri = $uriBuilder->uriFor($ControllerAction, $ParametersArray, $ControllerName, $ExtensionName, $PluginName);
//redirecting to selfmade Uri
return $this->redirectToUri($uri);

您錯過了提及使用的 TYPO3 核心版本。 在一些較新的核心版本中,extbase 支持請求/響應,在 extbase controller 操作中返回重定向響應可能不起作用。 如果您遇到這種情況,您應該能夠創建一個重定向響應並將其作為 PropagateResponseException 拋出,這會留下一些地方並跳轉到請求洋蔥中的外部位置 - 從而將正確的重定向返回到瀏覽器。

// build your uri with uri builder 
$redirectUri = $this->uriBuilder->uriFor(....);
$redirectResponse = new \TYPO3\CMS\Core\Http\RedirectResponse($redirectUri, 307, []);
throw new \TYPO3\CMS\Core\Http\PropagateResponseException($redirectResponse, 0);

你也可以使用 $this->redirect(..) 或 $this->rediretToUri() 方法來創建 $redirectResponse 並拋出它。

throw new \TYPO3\CMS\Core\Http\PropagateResponseException(
  $this->redirect(....), 0);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM