从 TYPO3 7 更新到 TYPO3 9 LTS 后的 Extbase / 类型问题
Extbase / type problem after update from TYPO3 7 to TYPO3 9 LTS
我有一个旧的 extbase 扩展,在从 7.6 更新到 TYPO3 9.5.8 后需要修复:
这行似乎是问题所在:
$this->registerArgument('background', FileReference::class . '|boolean', 'Image');
我得到的错误是
参数 "background" 注册为 "TYPO3\CMS\Extbase\Domain\Model\FileReference|boolean" 类型,但在视图助手
中是 "TYPO3\CMS\Extbase\Domain\Model\FileReference" 类型
但是,如果我删除 |boolean,我会得到一个新的错误,这次
参数 "background" 注册为 "TYPO3\CMS\Extbase\Domain\Model\FileReference" 类型,但在视图助手
中属于 "boolean" 类型
所以我有点陷入困境。有什么想法吗?
我在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;
}
所以我认为你必须使用
$this->registerArgument('background', TYPO3\CMS\Extbase\Domain\Model\FileReference, 'Image');
我可以通过将类型更改为 "string" 来解决问题。仍然不确定为什么之前它让我循环...
我有一个旧的 extbase 扩展,在从 7.6 更新到 TYPO3 9.5.8 后需要修复:
这行似乎是问题所在:
$this->registerArgument('background', FileReference::class . '|boolean', 'Image');
我得到的错误是
参数 "background" 注册为 "TYPO3\CMS\Extbase\Domain\Model\FileReference|boolean" 类型,但在视图助手
中是 "TYPO3\CMS\Extbase\Domain\Model\FileReference" 类型但是,如果我删除 |boolean,我会得到一个新的错误,这次
参数 "background" 注册为 "TYPO3\CMS\Extbase\Domain\Model\FileReference" 类型,但在视图助手
中属于 "boolean" 类型所以我有点陷入困境。有什么想法吗?
我在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;
}
所以我认为你必须使用
$this->registerArgument('background', TYPO3\CMS\Extbase\Domain\Model\FileReference, 'Image');
我可以通过将类型更改为 "string" 来解决问题。仍然不确定为什么之前它让我循环...