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

时间:2013-02-04 20:54:44

标签: symfony symfony-2.1 fosuserbundle

我有一个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>

我试图使用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));

任何提示都会非常感激。提前谢谢。

1 个答案:

答案 0 :(得分: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% } }

您使用错误的转储器也应使用Symfony\Component\DependencyInjection\Dumper\YamlDumper