doctrine / phpcr-odm

Doctrine PHPCR ODM
http://www.doctrine-project.org/projects/phpcr-odm.html
MIT License
183 stars 97 forks source link

Not possible to map references as translated fields. #612

Open dantleech opened 9 years ago

dantleech commented 9 years ago

Currently it is not possible to map references (@ReferenceOne, @ReferenceMany) as translated fields. This should be possible I think.

dbu commented 9 years ago

i can't think of a good reason why this should be forbidden, so i agree.

note that for hierarchy relations (parent, children), we can't limit to locale. neither for referrers. which brings me to realize: referrer mapping of a reference with child translation strategy will need some trick to go to the document and not just see the child node with the translation. or maybe we should just restrict translated references to attribute translation strategy for this reason?

dantleech commented 9 years ago

Not too familiar with the child translation strategy, would be a shame to make one strategy better than another, as it would mean people might get to a certain point and realise they need to migrate to the attribute strategy. Will have a look.

dbu commented 9 years ago

well, the referrers are done on phpcr level. and child translation strategy means translated fields are stored in a translation child node of the main node of the document. so the referrer would see a GenericDocument that represents the translation, rather than the actual document. we may be able to detect that situation and go to the parent. it will also be tricky with the field name of the referrer, as for attribute strategy, the property name depends on the language. maybe in the end we should have referrers also support translated and figure out the correct property name for attribute strategy and filter out the child translation nodes that are not of the correct locale.