我有 XML 服务:
<service id="sonata.news.admin.comment" class="%sonata.news.admin.comment.class%">
<tag name="sonata.admin" manager_type="orm" group="sonata_blog" label="comments" label_catalogue="%sonata.news.admin.comment.translation_domain%" label_translator_strategy="sonata.admin.label.strategy.underscore" />
<argument />
<argument>%sonata.news.admin.comment.entity%</argument>
<argument>%sonata.news.admin.comment.controller%</argument>
<call method="setTranslationDomain">
<argument>%sonata.news.admin.comment.translation_domain%</argument>
</call>
<call method="setCommentManager">
<argument id="sonata.news.manager.comment" type="service"/>
</call>
<call method="setTemplates">
<argument type="collection">
<argument key="inner_list_row">SonataNewsBundle:Admin:inner_row_comment.html.twig</argument>
<argument key="base_list_field">SonataAdminBundle:CRUD:base_list_flat_field.html.twig</argument>
</argument>
</call>
</service>
如何将此服务转换为 yaml?我可以:
sonata.news.admin.comment:
class: Sonata\NewsBundle\Admin\CommentAdmin
tags:
- { name: sonata.admin, manager_type: orm, group: "sonata_blog", label: "comments" }
arguments:
- ~
- Sonata\NewsBundle\Entity\Comment
- Sonata\NewsBundle\Controller\Comment
calls:
- [ setTranslationDomain, [SonataNewsBundle]]
- [ setCommentManager ]
除了最后一行 - setCommentManager 之外,所有工作都很好。我有错误:
CommentAdmin::setCommentManager() must be an instance of Sonata\NewsBundle\Model\CommentManagerInterface, none given
我怎样才能通过这个实例?
可能我如何将 xml 文件中的此服务导入 yaml?
我想对此服务进行一些更改。
编辑: Next ii 想在此服务中传递 SetTemplates,但是我如何在这个示例中使用 2 个参数?