Symfony 3 - 如何在运行时更改配置值

时间:2017-07-03 10:43:57

标签: symfony

处理必须在运行时发生的配置参数(保留在yml中)的更改的最佳实践方法是什么?

我正在开发一个网站,其中所有者想要更改其管理员后端中的各种设置。 例如,当新用户注册帐户时,启用/禁用FOS用户捆绑包发送的确认电子邮件和链接。

感谢您的时间

1 个答案:

答案 0 :(得分:0)

对于这些操作,您需要使用Compiler Pass。

https://symfony.com/doc/current/service_container/compiler_passes.html

此处示例自定义编译器传递;

https://symfony.com/doc/current/components/dependency_injection/compilation.html#creating-separate-compiler-passes

这是编译器传递的一个很好的例子; (通常与服务标签一起使用)

https://symfony.com/doc/current/service_container/tags.html