[英]Extbase / type problem after update from TYPO3 7 to TYPO3 9 LTS
I have an old extbase extension that needs to be fixed after updating from 7.6 to TYPO3 9.5.8: 我有一个旧的extbase扩展,从7.6更新到TYPO3 9.5.8后需要修复:
This line seems to be the problem: 这行似乎是问题所在:
$this->registerArgument('background', FileReference::class . '|boolean', 'Image');
The error I get is 我得到的错误是
The argument "background" was registered with type "TYPO3\\CMS\\Extbase\\Domain\\Model\\FileReference|boolean", but is of type "TYPO3\\CMS\\Extbase\\Domain\\Model\\FileReference" in view helper 参数“ background”已在类型“ TYPO3 \\ CMS \\ Extbase \\ Domain \\ Model \\ FileReference | boolean”中注册,但在视图助手中的类型为“ TYPO3 \\ CMS \\ Extbase \\ Domain \\ Model \\ FileReference”
However, if I remove the |boolean I get a new error, this time 但是,如果我除去| boolean,则会出现新错误,这一次
The argument "background" was registered with type "TYPO3\\CMS\\Extbase\\Domain\\Model\\FileReference", but is of type "boolean" in view helper 参数“背景”已注册为类型“ TYPO3 \\ CMS \\ Extbase \\ Domain \\ Model \\ FileReference”,但在视图帮助器中的类型为“布尔”
So I am kind of in a loop here. 所以我有点陷入困境。 Any ideas? 有任何想法吗?
I found the function in typo3_src/vendor/typo3fluid/fluid/src/Core/ViewHelper/AbstractViewHelper 我在typo3_src / vendor / typo3fluid / fluid / src / Core / ViewHelper / AbstractViewHelper中找到了该功能
/**
* Register a new argument. Call this method from your ViewHelper subclass
* inside the initializeArguments() method.
*
* @param string $name Name of the argument
* @param string $type Type of the argument
* @param string $description Description of the argument
* @param boolean $required If TRUE, argument is required. Defaults to FALSE.
* @param mixed $defaultValue Default value of argument
* @return \TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper $this, to allow chaining.
* @throws Exception
* @api
*/
protected function registerArgument($name, $type, $description, $required = false, $defaultValue = null)
{
if (array_key_exists($name, $this->argumentDefinitions)) {
throw new Exception(
'Argument "' . $name . '" has already been defined, thus it should not be defined again.',
1253036401
);
}
$this->argumentDefinitions[$name] = new ArgumentDefinition($name, $type, $description, $required, $defaultValue);
return $this;
}
So I think you have to use 所以我认为你必须使用
$this->registerArgument('background', TYPO3\CMS\Extbase\Domain\Model\FileReference, 'Image');
I was able to solve the issue by turning the type to "string". 我可以通过将类型更改为“字符串”来解决此问题。 Still not sure why It sent me in a loop before... 仍然不确定为什么它让我在之前...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.