1

谁能告诉我将 xml 转换为 yaml 的问题是什么?(我试过这样做,但我收到一个错误,上面写着“你不能在映射中定义序列项”)

<service id="sonata.news.admin.post" class="%sonata.news.admin.post.class%">
    <tag name="sonata.admin" manager_type="orm" group="sonata_blog" label="post"/>
    <argument />
    <argument>%sonata.news.admin.post.entity%</argument>
    <argument>%sonata.news.admin.post.controller%</argument>

    <call method="setUserManager">
        <argument type="service" id="fos_user.user_manager" />
    </call>

</service>

并转换为 yaml 文件:

sonata.news.admin.post:
    class: "%sonata.news.admin.post.class%"
    arguments: [%sonata.news.admin.post.entity%]
    arguments: [%sonata.news.admin.post.controller%]
    tags:
        - { name: sonata.admin, manager_type: orm, group: sonata_blog, label: post}
    call:
        - {method: setUserManager}
        service:
            fos_user.user_manager
4

1 回答 1

1

您的语法完全错误……请阅读文档,即如何将setter 注入与 YAML 一起使用。

arguments: [%sonata.news.admin.post.entity%]
arguments: [%sonata.news.admin.post.controller%]

应该

arguments: [%sonata.news.admin.post.entity%, %sonata.news.admin.post.controller%]

... 更远

call:
    - {method: setUserManager}
    service:
        fos_user.user_manager

... 应该

 calls: 
     - [setUserManager, ["@fos_user.user_manager"]]
于 2013-07-19T14:37:02.137 回答