繁体   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