Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for "Indexed Associations" as in the Doctrine ORM #701

Closed
koemeet opened this issue Apr 17, 2016 · 3 comments
Closed

Support for "Indexed Associations" as in the Doctrine ORM #701

koemeet opened this issue Apr 17, 2016 · 3 comments
Labels

Comments

@koemeet
Copy link
Contributor

koemeet commented Apr 17, 2016

I could not find a way to make a reference-many association indexed by a specific field or it's node name. In the Doctrine ORM there is something like the indexBy mapping, that you can use to get an associative collection. Is support for this in PHPCR ODM something that might happen?

We could achieve this by adding the appropriate code to the ReferenceManyCollection::initialize method.

@dbu
Copy link
Member

dbu commented Apr 18, 2016

sounds like a useful feature. however, what happens if the index is not unique? using the full path of the target documents would be unique. the node name can not be guaranteed to be unique, and neither a field of a document.

why did you close #702, did it not work?

@koemeet
Copy link
Contributor Author

koemeet commented Apr 18, 2016

Well I used that branch to fix the issue for me for now, making a PR was by accident. But if you like it I can reopen it.

The reason I only wanted the node name to be the index is because I am using the translations system from the ResourceBundle of Sylius. They require that the collection is indexed by it's locale. I wanted to avoid a different translation strategy for PHPCR documents and make it work the same way as translations do for ORM entities.

I am curious how a node name can be not unique in the same parent document? I have never been able to make a node at the same parent with the same name.

@dbu
Copy link
Member

dbu commented Apr 18, 2016

within the children collection, names indeed will be unique, and there it would make a ton of sense to index by name.

with references, you can reference arbitrary documents. if you reference /a/b/c and /b/b/c then both local names will be "c".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants