Symfony2 实体注解中的可配置参数 [英] Configurable parameters in Symfony2 entity annotation

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

问题描述

我正在尝试按照 教义博客.但是,该示例建议将数据库名称直接硬编码到架构中,出于显而易见的原因,我希望避免这种情况.

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.

有没有办法读取 parameters.iniconfig.yml 中定义的参数并将它们用作注释的值,像这样?

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%")
 */

推荐答案

不,这是不可能的.%key%"表单仅在 DIC 中可用.为什么要将这些数据放在 yml 文件中?有用吗?

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天全站免登陆