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