rat4m3n
rat4m3n

Reputation: 1201

Convert fos user bundle service into yml

I have a FosUserBundle service I need to convert to yml format. How can I do this is there a dumper convertor or anything?

How this would look in 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>

I was trying to use Yml dumper but this is just giving me serialised object:

    $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));

Any tips would be much appreciated. Thanks in advance.

Upvotes: 3

Views: 3292

Answers (1)

l3l0
l3l0

Reputation: 3393

You can try do it in such way:

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% } }

You use wrong dumper as well you should use Symfony\Component\DependencyInjection\Dumper\YamlDumper

Upvotes: 7

Related Questions