我正在跟踪这里的文档:https://docs.sulu.io/en/2.2/cookbook/smart-content-data-provider.html
试图为我的自定义实体类型“MatchEvent”创建自定义数据提供程序:
我做到了这是怎么解释的。因为我有services.yaml文件,所以我像这样定义了这两个文件:
app.match_event_repository:
class: App\Repository\MatchEventRepository
factory: ['@doctrine', 'getRepository']
arguments:
- Symfony\Bridge\Doctrine\ManagerRegistry
app.smart_content.data_provider.matchevent:
class: App\SmartContent\MatchEventDataProvider
arguments: ['@app.match_event_repository', '@sulu_core.array_serializer', '@request_stack' ]
tags: [{name: 'sulu.content.type', alias: 'smart_matchevent_selection'}]因此,如果我理解得很好,那么在此之后,我应该有一个名为"smart_matchevent_selection“的自定义内容数据提供程序,我可以这样使用它:
<property name="match" type="smart_content">
<meta>
<title lang="en">Match</title>
<title lang="de">Match</title>
</meta>
<params>
<param name="provider" value="smart_matchevent_selection"/>
</params>
</property>但是,当我试图编辑包含此字段的页面时,会出现以下错误:
Sulu\Bundle\PreviewBundle\Controller\PreviewController中的缺失参数令牌
异常在project/vendor/sulu/sulu/src/Sulu/Bundle/PreviewBundle/Controller/PreviewController.php触发
public function stopAction(Request $request): Response
{
$this->preview->stop($this->getRequestParameter($request, 'token', true));
return new JsonResponse();
}我在这里做错了什么?
发布于 2021-05-26 09:42:28
如果仔细查看文档中SmartContentDataProvider的服务定义,您会注意到标记应该是{name: 'sulu.smart_content.data_provider', alias: 'match_events'}而不是{name: 'sulu.content.type', alias: 'smart_matchevent_selection'} .
然后您可以像使用<param name="provider" value="match_events"/>一样使用它。
https://stackoverflow.com/questions/67702169
复制相似问题