简体   繁体   English

Symfony-使用前端控制器获取parameters.yml

[英]Symfony - get parameters.yml with front Controller

I have a legacy application. 我有一个旧版应用程序。

I must get some parameters from parameters.yml in FrontController (app.php or app_dev.php) before system initialize Symfony Security Firewall. 在系统初始化Symfony安全防火墙之前,我必须从FrontController中的parameter.yml(app.php或app_dev.php)中获取一些参数。 This parameter is path to config file ( this config is outside my project - config is required for connect to "library" with my model). 此参数是配置文件的路径(此配置在我的项目外部-使用我的模型连接到“库”时需要配置)。 Model is outside my project. 模型不在我的项目中。

I must include this library by "include" function, composer drops. 我必须通过“ include”功能包括该库,composer会删除。

In my system I have securityController, and userProvider which connect to database by "library". 在我的系统中,我具有securityController和userProvider,它们通过“库”连接到数据库。

So I don't know how can I get parameter with paramters.yml in FrontController. 所以我不知道如何在FrontController中使用paramters.yml获取参数。

I'm afraid you couldn't, Symfony Firewall is always be run before the request hit to controller. 恐怕您做不到,Symfony Firewall始终在请求到达控制器之前运行。

So in your scenario, I think you should go to your security event listener (not sure what is the type of firewall you are using, x509, simple token...), so you can get parameter normally by $container->getParameter() and store it in somewhere, then controller can read it 因此,在您的情况下,我认为您应该转到安全事件侦听器(不确定使用的防火墙类型,x509,简单令牌...),以便可以通过$container->getParameter()并将其存储在某个地方,然后控制器可以读取它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM