本文介绍了“传递给 ViewHelper 的未声明参数"例外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
限时送ChatGPT账号..更新 TYPO3 后,我得到一个 TYPO3Fluid\Fluid\Core\ViewHelper\Exception
传递给 ViewHelper 的未声明参数......有效参数是."
After updating TYPO3, I get a TYPO3Fluid\Fluid\Core\ViewHelper\Exception
"Undeclared arguments passed to ViewHelper ... Valid arguments are."
推荐答案
这可能是由于使用已删除功能的扩展.仅使用 TYPO3 内核,您应该不会看到此错误.
This may be due to an extension using functionality that has been dropped. Using only the TYPO3 core, you should not see this error.
在您的扩展中:如果您仍然在带有参数的 ViewHelper 类中使用 render() 方法,您可能需要替换:
In your extension: If you still use the render() method in your ViewHelper class with arguments, you may want to replace this:
之前:
public function render(Mail $mail, $type = 'web', $function = 'createAction')
<小时>
之后:
public function initializeArguments()
{
parent::initializeArguments();
$this->registerArgument('mail', Mail::class, 'Mail', true);
$this->registerArgument('type', 'string', 'type: web | mail', false, 'web');
$this->registerArgument('function', 'string', 'function: createAction | senderMail | receiverMail', false, 'createAction');
}
public function render()
{
$mail = $this->arguments['mail'];
$type = $this->arguments['type'] ?? 'web';
// ...
}
<小时>
另外,
如果不需要使用 render()(例如,除非您需要访问 $this 变量),您可能需要切换到 renderStatic() 以获得性能原因(另见这个其他StackOverflow 回答 澄清)从TYPO3Fluid\Fluid\Core\ViewHelper
中的类继承而不是TYPO3\CMS\Fluid\Core\ViewHelper
:
if there is no need to use render() (e.g. unless you need to access $this variables), you may want to switch to renderStatic() for performance reasons (see also this other StackOverflow answer for clarification)
inherit from classes in TYPO3Fluid\Fluid\Core\ViewHelper
instead of TYPO3\CMS\Fluid\Core\ViewHelper
:
// use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
<小时>
文档:
开发自定义 ViewHelper变更日志:
突破性:#82414 - 删除了 CMS ViewHelper 基类弃用:#81213 - 不推荐使用 ViewHelpers 上的渲染方法参数突破:#87193 - 已删除不推荐使用的功能(10 个) Breaking: #82414 - CMS ViewHelper base classes removed Deprecation: #81213 - Render method arguments on ViewHelpers deprecated Breaking: #87193 - Deprecated functionality removed (for 10)这篇关于“传递给 ViewHelper 的未声明参数"例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论