XML转YAML转换

Ced*_*ric 2 xml yaml symfony

我怎样才能将其转换为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>
Run Code Online (Sandbox Code Playgroud)

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

fos_user.mailer.twig_swiftr:
    class: FOS\UserBundle\Mailer\TwigSwiftMailer
    arguments: ['@mailer', '@router', '@twig']
Run Code Online (Sandbox Code Playgroud)

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

Ram*_*esh 7

尝试:

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% } }
Run Code Online (Sandbox Code Playgroud)

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

  • 你打了它!谢谢..我是YAML的新手,你的答案给了我未来应用的提示......这对我帮助很大...... (2认同)

Pau*_*een 5

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

Symfony2 Service Config Converter