-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add support for nesting embeddables #1105
Conversation
Hello, thank you for creating this pull request. I have automatically opened an issue http://www.doctrine-project.org/jira/browse/DDC-3249 We use Jira to track the state of pull requests and the versions they got |
foreach ($class->embeddedClasses as $property => $embeddableClass) { | ||
|
||
if (isset($embeddableClass['inherited'])) { | ||
continue; | ||
} | ||
|
||
if ($embeddableClass['class'] === $class->name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not the only case leading to an infinite nesting. You need to account for loops as well: A embed B embed A
(and with any length for the cycle of course)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A good way to solve this is to keep an internal reference map (new property in the CMF) somehow. Finding loops would be easy then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I almost expected to be missing something here. Meh that is tricky... Have to think about a reasonable solution here :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private $embeddablesInheritance = [];
and then
private function checkEmbeddablesInheritance($embeddableName, $looping = [])
{
// do the recursion stuff here
}
Something like that. I suggest starting from a test, as it makes it much easier to write the recursion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ocramius thanks I will try that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another data structure would maybe even be cleaner: could just be a small, final
InheritanceMap
object/utility
Add support for nesting embeddables
Awesome, thanks! :) |
This seems to be broken again? If I have an entity, which has an embeddable, which has an embeddable the schema tool explodes with the message: Peasant::$priest.person.id does not exist |
This is a possible approach towards adding support for nesting embeddables (embeddables inside embeddables). I'm not sure whether this implementation is the best solution but I think it is something to start with. It seems to work flawlessly so far but I'm not sure if I missed something, so any feedback is welcome ;)