在EntityRepository中获取Symfony容器 [英] Get Symfony Container in an EntityRepository

查看:164
本文介绍了在EntityRepository中获取Symfony容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在parameters.ini中设置了一个变量,但是现在我想从EntityRepository中检索该变量,并且$this->container未设置,所以我不能这样做

I've set a variable in parameters.ini, but now I want to retrieve that variable from an EntityRepository and $this->container is unset so I can't do it

我应该如何到达容器?

谢谢:)

推荐答案

您不应在EntityRepository中使用$ container.相反,创建模型管理器服务,然后通过DI注入容器.

You should not use $container in the EntityRepository. Instead, create a Model Manager service and inject the container through DI.

这篇关于在EntityRepository中获取Symfony容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆