从TYPO3 v9升级到v10后:显示页面不再工作(无法访问受保护的属性)



我已经编写了一个基于TYPO3版本9的扩展。我现在已经把它安装在TYPO3版本10的系统中,一切似乎都很好。只能打开显示页面。

错误来了:

Cannot access protected property mynamemyextensionDomainModelCountry::$name

我不明白这个错误。在列表页上,我通常使用国家名称。在"显示"页面上,我根本不使用它。因此,为什么这会引起问题是没有道理的。

这是我的Show.html

<div class="card">
<h5 class="card-header" style="text-align: center">
{house.name}
</h5>
<div class="card-body" style="text-align: center">
<p class="card-text">
<f:link.external uri="{house.link}" target="_blank">{house.link}</f:link.external>
</p>
<h2>Rooms</h2>
<ul>
<f:for each="{house.room}" as="room">
<li>{room.name}</li>
</f:for>
</ul>
</div>
</div>
<f:link.action action="list" class="btn btn-primary">
BACK
</f:link.action>

我的控制器

class HouseController extends TYPO3CMSExtbaseMvcControllerActionController
{
............
............
/**
* @param House $house
*/
public function showAction(House $house)
{
$this->view->assign('house', $house);
}

如前所述,完整的代码在版本9上运行良好,在版本10中必须有一些更改的问题。

编辑:这是我的国家型号

class Country extends TYPO3CMSExtbaseDomainObjectAbstractEntity
{
/**
* Country Name
* 
* @var string
* @TYPO3CMSExtbaseAnnotationValidate("NotEmpty")
*/
protected $name = '';
/**
* Returns the name
* 
* @return string $name
*/
public function getName()
{
return $this->name;
}
/**
* Sets the name
* 
* @param string $name
* @return void
*/
public function setName($name)
{
$this->name = $name;
}
}

这里是我的房屋模型(并非所有线路(:

class House extends TYPO3CMSExtbaseDomainObjectAbstractEntity
{
/**
* __construct
*/
public function __construct()
{
//Do not remove the next line: It would break the functionality
$this->initStorageObjects();
}
/**
* Countrie House
* 
* @var mynamemyextensionDomainModelCountry
* @TYPO3CMSExtbaseAnnotationORMLazy
*/
protected $country = null;
/**
* Returns the country
* 
* @return mynamemyextensionDomainModelCountry $country
*/
public function getCountry()
{
return $this->country;
}
/**
* Sets the country
* 
* @param mynamemyextensionDomainModelCountry $country
* @return void
*/
public function setCountry(mynamemyextensionDomainModelCountry $country)
{
$this->country = $country;
}
}

问题是您使用@TYPO3CMSExtbaseAnnotationORMLazy与模型建立直接关系。@TYPO3CMSExtbaseAnnotationORMLazy注释有助于将其用于ObjectStorage,不建议直接用于其他模型。

这似乎是TYPO3核心中的一个错误-另请参阅:https://forge.typo3.org/issues/92357

最新更新