![](/img/trans.png)
[英]TYPO3 - Extbase extension won't render record information after upgrade from 7LTS to 8LTS
[英]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.