XML转YAML转换

时间:2014-03-03 02:35:34

标签: xml symfony yaml

如何将其转换为yml

    <service id="fos_user.mailer.twig_swift" class="FOS\UserBundle\Mailer\TwigSwiftMailer" public="false">
        <argument type="service" id="mailer" />
        <argument type="service" id="router" />
        <argument type="service" id="twig" />
        <argument type="collection">
            <argument key="template" type="collection">
                <argument key="confirmation">%fos_user.registration.confirmation.template%</argument>
                <argument key="resetting">%fos_user.resetting.email.template%</argument>
            </argument>
            <argument key="from_email" type="collection">
                <argument key="confirmation">%fos_user.registration.confirmation.from_email%</argument>
                <argument key="resetting">%fos_user.resetting.email.from_email%</argument>
            </argument>
        </argument>
    </service>

现在我在转换方面做得很远:

fos_user.mailer.twig_swiftr:
    class: FOS\UserBundle\Mailer\TwigSwiftMailer
    arguments: ['@mailer', '@router', '@twig']

<argument type = "collection">是我坚持的路线。感谢。

2 个答案:

答案 0 :(得分:6)

尝试:

fos_user.mailer.twig_swiftr:
    class: FOS\UserBundle\Mailer\TwigSwiftMailer
    arguments:
        - @mailer
        - @router
        - @twig
        - { template: { confirmation: %fos_user.registration.confirmation.template%, resetting: %fos_user.resetting.email.template% }, from_email: { confirmation: %fos_user.registration.confirmation.from_email%, resetting: %fos_user.resetting.email.from_email% } }

请检查:http://symfony.com/doc/current/components/yaml/yaml_format.html#collections

答案 1 :(得分:5)

有一个简洁的在线工具,可将Symfony XML 配置转换为 YAML

<强> Symfony2 Service Config Converter