将fos用户捆绑服务转换为yml

rat*_*m3n 3 symfony fosuserbundle symfony-2.1

我有一个FosUserBundle服务,我需要转换为yml格式.我怎么能这样做是有翻斗车转换器还是其他什么?

这在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)

我试图使用Yml转储器,但这只是给我序列化的对象:

    $cs = new ContainerBuilder();

    $loader1 = new Loader\XmlFileLoader($cs, new FileLocator(__DIR__ . '/../../../../vendor/friendsofsymfony/user-bundle/FOS/UserBundle/Resources/config'));
    $loader1->load('mailer.xml');

    $dumper = new \Symfony\Component\Yaml\Dumper();

    file_put_contents(__DIR__ . '/test2.yml', $dumper->dump($cs));
Run Code Online (Sandbox Code Playgroud)

任何提示将非常感激.提前致谢.

l3l*_*3l0 7

您可以尝试以这种方式执行此操作:

services:
    fos_user.mailer.twig_swift:
        class: FOS\UserBundle\Mailer\TwigSwiftMailer
        arguments:
            - @mailer
            - @router
            - @templating
            - { 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)

你也应该使用错误的翻斗车 Symfony\Component\DependencyInjection\Dumper\YamlDumper