Symfony yml 参数到 doctrine yml 映射
Symfony yml parameters into doctrine yml mapping
我有一个关于 doctrine yml 文件的问题。是否可以导入 yml 配置文件,例如 parameters.yml 并将这些参数用于映射配置?
例如,这是我想做的:
imports:
- { resource: parameters.yml }
Yunai39\Bundle\SimpleLdapBundle\Entity\RoleLdap:
type: entity
id:
id:
type: integer
id: true
generator:
strategy: AUTO
fields:
roleName:
type: string
length: '255'
manyToMany:
users:
targetEntity: "%user_class%"
mappedBy: roles
有谁知道这是否可能?
不,这不可能。
不过,您可能会对 Resolving Target Entities 感兴趣,因为看起来您正在尝试这样做。
Doctrine 2.2 includes a new utility called the ResolveTargetEntityListener, that functions by intercepting certain calls inside Doctrine and rewriting targetEntity parameters in your metadata mapping at runtime. It means that in your bundle you are able to use an interface or abstract class in your mappings and expect correct mapping to a concrete entity at runtime.
我有一个关于 doctrine yml 文件的问题。是否可以导入 yml 配置文件,例如 parameters.yml 并将这些参数用于映射配置?
例如,这是我想做的:
imports:
- { resource: parameters.yml }
Yunai39\Bundle\SimpleLdapBundle\Entity\RoleLdap:
type: entity
id:
id:
type: integer
id: true
generator:
strategy: AUTO
fields:
roleName:
type: string
length: '255'
manyToMany:
users:
targetEntity: "%user_class%"
mappedBy: roles
有谁知道这是否可能?
不,这不可能。
不过,您可能会对 Resolving Target Entities 感兴趣,因为看起来您正在尝试这样做。
Doctrine 2.2 includes a new utility called the ResolveTargetEntityListener, that functions by intercepting certain calls inside Doctrine and rewriting targetEntity parameters in your metadata mapping at runtime. It means that in your bundle you are able to use an interface or abstract class in your mappings and expect correct mapping to a concrete entity at runtime.