typo3 - Typo3 9.5 子类和外部表
问题描述
在 Typo3 9.5 中使用单表继承时,如何为子类中定义的属性指定外部表?
我在 ext_typoscript_setup.txt 中定义了类继承:
config.tx_extbase.persistance.classes {
MyProject\Base { mapping {
tablename = tx_myproject_base
subclasses = {
1 = MyProject\Derived
}
}}
MyProject\Derived { mapping {
tablename = tx_myproject_base
recordType = 1
columns = {
choice.mapOnProperty = selection
}
}}
MyProject\Choice { mapping {
tablename = tx_myproject_choice
}}
}
在 Configuration/TCA/tx_myproject_base.php 中,我有
return [
'ctrl' => ['type' => 'subclass'],
'columns' => [
// some fields of the base type
// and now the fields of the derived type
'choice' => [
'config' => [
'type' => 'select',
'foreign_table' => tx_myproject_choice,
'size' => 1,
'minitems' => 0, 'maxitems' => 1,
'renderType' => 'selectSingle',
]
]]
];
所以派生对象有一个外键进入选择,在数据库中称为选择,在 php 中称为选择。
当我在控制器中执行 setOrderings('selection.ranking'=>DESCENDING) 时,出现错误
The relation information for property "selection" of class "MyProject\Derived" is missing.
在调试输出中,我看到该字段已正确映射到选择字段,但缺少 foreign_table 信息。
我假设问题是我在基表的 PHP 文件中有子类的 TCA 配置,但我不知道如何解决这个问题。
如何让 Extbase 理解子类型的字段是外来模型的关键?
解决方案
推荐阅读
- ffmpeg - ffmpeg如何根据时间触发颜色变化
- android - 通过改造 android (kotlin) 向特定主题发送 fcm 消息
- python - 将动态输入传递给 flask-user @roles_required 装饰器
- nuxt.js - 为什么我在查看源代码中看到 vuetify css?
- angular - Web浏览器上的离子角度测试PushNotifications
- javascript - 在 React.JS 中处理 API 调用的输入更改
- .net - RabbitMQ 异常“指定的端点均不可到达”
- c++ - 程序以获取所有输入而不显示任何内容结束
- vscode-extensions - 如何仅在 vscode 扩展的资源管理器上下文菜单中显示命令?
- r - 如何将函数结果添加到列表中