symfony - 将 fos 用户包服务转换为 yml

标签 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 dumper,但这只是给我序列化的对象:

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

如有任何提示,我们将不胜感激。提前致谢。

最佳答案

你可以尝试这样做:

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

关于symfony - 将 fos 用户包服务转换为 yml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14695464/

相关文章:

php - 交响乐 2 : Get Security Context Outside of Controller

php - 全局覆盖 symfony2.1 上的 NotBlank Constraint Message?

symfony - 在 Doctrine 2 中更新(从反面)双向多对多关系?

symfony-2.1 - 当供应商在 Symfony 2.1 中没有使用 composer 进行管理时,在哪里注册自动加载?

symfony - 事件监听器未在 Doctrine 事件上注册或调用

php - FOSUserBundle:如何允许注册、确认但不激活?

php - Symfony 生产映射异常 FOSUserBundle

javascript - Searchfuntion 在 Symfony2 中使用 ajax 调用

mysql - 使用 findBy 访问实体内的 ArrayCollection

forms - Symfony2 FOSUserBundle – 验证登录时的 "user active"标志