在Symfony2的实体注释配置参数 [英] Configurable parameters in Symfony2 entity annotation

查看:185
本文介绍了在Symfony2的实体注释配置参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图创建跨多个数据库的连接(属于遗留应用其中之一)作为的博客学说。然而,例子表明硬编码数据库的名称右转入架构,我想避免的原因很明显它。

有没有办法读取定义的参数 parameters.ini config.yml 并把它们作为一个对于标注值,也是这样吗?

  / **
 * @ORM \\表(名称=%legacy_db_name%。%legacy_table_name%)
 * /


解决方案

没有,这是不可能的。在%键%的形式只在DIC可用。
为什么你会把这些数据在阳明文件?难道是有用的?

I'm trying to create a join across multiple databases (one of them belonging to a legacy application) as described in the Doctrine blog. However, the example suggests hardcoding the name of the database right into the schema, which I'd like to avoid for obvious reasons.

Is there a way to read parameters defined in parameters.ini or config.yml and use them as a value for the annotations, like this?

/**
 * @ORM\Table(name="%legacy_db_name%.%legacy_table_name%")
 */

解决方案

No, it's impossible. The "%key%" form is only available in the DIC. Why would you put these data in a yml file? Would it be useful?

这篇关于在Symfony2的实体注释配置参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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