mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
Issue with loading additional associated entities during postLoad #5302
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @yellow1912 on GitHub (Oct 26, 2016).
Sorry for the lack of better wording for the question, as I'm not so sure how to describe the problem in a few words.
In my Symfony project with the latest Doctrine (~2.5), to create a form of dynamic association, I need to automatically load additional entities then assign to the current object before I return the object.
A simple version of the code looks like this
In the code, I use the repository to query the additional entities then assign to the current entity. The problem I'm facing is that if these additional entities have association with other entities as well, then these associated fields will not be fetched. When dumped, the "initialized" value is always set to false, and even in the case that I explicitly attempt to fetch the it still doesn't work.
So
$repository->find($data)->getValues() // getValues() access a referenced collection, but in this case it will still return an empty CollectionI'm not sure if it helps but pre-update to Doctrine 2.5 and Symfony 3.x this code used to work.
@yellow1912 commented on GitHub (Oct 26, 2016):
Upon further investigation it is actually a logic issue in my code, ___