繁体   English   中英

从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,则会出现新错误,这一次

参数“背景”已注册为类型“ TYPO3 \\ CMS \\ Extbase \\ Domain \\ Model \\ FileReference”,但在视图帮助器中的类型为“布尔”

所以我有点陷入困境。 有任何想法吗?

我在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');

我可以通过将类型更改为“字符串”来解决此问题。 仍然不确定为什么它让我在之前...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM