xml到yaml:在映射中无法定义序列项

时间:2013-07-19 14:25:55

标签: xml symfony yaml

任何人都可以告诉我将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

1 个答案:

答案 0 :(得分:0)

您的语法完全错误...请阅读文档,即如何将setter injection与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"]]