I have a mapped-superclass with a string property 'name' which belongs to a bundle (SyliusAssortmentBundle, actually). I have a class in my bundles that inherits from that mapped-superclass. I'd like to add Translatable capabilities to my entity by using DoctrineExtensions (Translatable). Since I cannot redeclare the property 'name' in my mapping, I am trying to override the mapping of that property following this doctrine documentation:
http://docs.doctrine-project.org/en/latest/reference/inheritance-mapping.html#attribute-override
Inspired by this, I added this to my product.orm.xml file
<attribute-overrides>
<attribute-override name="name">
<field name="name" column="name" type="string">
<gedmo:translatable/>
</field>
</attribute-override>
</attribute-overrides>
this doesn't seem to be working. I have added a dummie property (trans_name) to my entity so I am sure that the Translatable Extension is working.
<field name="trans_name" type="string">
<gedmo:translatable/>
</field>
After persisting with something like:
$e->setTranslatableLocale('fr_fr');
$e->setName('name fr');
$e->setTransName('trans name fr');
just the 'trans_name' has been saved to 'ext_translations' table.
So. Is it possible to override the mapping and add Translatable? If so. What am I doing wrong?...
thanks
As far as I know the @AttributeOverrides
, @AssociationOverrides
, etc annotations are introduced to override Doctrine's fields and associations. Overriding other annotations (like @Gedmo\\Translatable
) is not supported.
As alternative you could copy/paste the mappings to your own bundle, add the extra ones you need (like @Gedmo\\Translatable
) and load these mappings in stead of the ones from SyliusAssortmentBundle.
假设问题在几年前已经解决,但是我刚刚在gedmo/doctrine-extensions
创建了拉取请求,因为碰到了同样的问题: https : //github.com/Atlantic18/DoctrineExtensions/pull/1631
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.