简体   繁体   English

如何在教义注释中设置变量?

[英]How to set variable in doctrine anotation?

I'm wondering how if it's possible, to inject variable into my doctrine anotation : 我想知道如何将变量注入我的学说注释中:

<?php
/**
* @Entity
* @Table(name="ecommerce_products")
*/
class ECommerceProduct
{
}

Assuming ecommerce_products is a variable 假设ecommerce_products是一个变量

Dont know if this is a recommended troubleshooting but it's fixed the issue. 不知道这是否是建议的故障排除方法,但已解决了该问题。 I use a constant as follow: 我使用如下常量:

<?php

 ...

define('ProductsTable', 'ecommerce_products')

/**
* @Entity
* @Table(name=ProductsTable)
*/
class ECommerceProduct
{
}

Notice the absence of quotes. 注意没有引号。 Thus symfony consideres it as a constant. 因此,symfony将其视为常数。 What give us lot of ways to set it from anywhere outside. 是什么让我们有很多方法可以从外部任何地方进行设置。

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

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