【发布时间】:2021-05-27 13:29:53
【问题描述】:
我正在关注关于创建自定义数据提供者的官方 sulu 文档:
https://docs.sulu.io/en/2.2/cookbook/smart-content-data-provider.html#dataprovider
这里,在 ExampleDataProvider 类里面,在 getConfiguration() 方法里面有一段代码:
->enableTypes([
['type' => 'example-type-1', 'title' => 'type-translation-key-1'],
['type' => 'example-type-2', 'title' => 'type-translation-key-2'],
])
对于我的存储库类,我正在使用 DataProviderRepositoryTrait 特征,正如那里所建议的那样。
这些类型是什么?可以排除在外吗。我认为它们与智能字段类型的过滤器有关,但我不明白这是如何工作的。
更新:
实际问题是什么 - 当我尝试在后端打开编辑页面时,我的智能类型出现在我收到错误消息:
[Semantical Error] line 0, col 84 near 'type WHERE entity.id': Error: Class App\Entity\MatchEvent has no association named type
我尝试只排除添加启用类型的代码,但它是相同的。
错误地说,即使我排除了启用的类型,某些 sql 查询仍在寻找某些类型参数,但我不知道在哪里以及如何解决这个问题。
我在这里发现了一些类似的问题:How do i solve Semantical error: "Class has no association named.."
因此,如果问题相同,则意味着应将字段“type”添加到我的自定义实体类型中。但是这篇教程文章中没有提到?
我想通了:
public function appendJoins(QueryBuilder $queryBuilder, $alias, $locale)
{
$queryBuilder->addSelect('type')->leftJoin($alias . '.type', 'type');
}
在实现 DataProviderRepositoryInterface 接口时,我必须在我的存储库类中添加此“类型”以进行查询。如果我注释掉该行,我不会再收到错误,但我的字段永远不会完成加载(微调器无限运行)
【问题讨论】:
标签: sulu