-
-
Notifications
You must be signed in to change notification settings - Fork 505
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
Decouple UnitOfWork from Hydrators #2641
Conversation
* | ||
* @psalm-return class-string | ||
*/ | ||
public function getClassNameForAssociation(array $mapping, $data): string |
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.
I'm not a fan of expanding DM's public surface but I'm not sure where else this could go... definitely not into generated hydrators as maintaining that will be PITA, ClassMetadataFactory is a no-go because of interface.
So just a food for thought, no other concerns from my end 👌
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.
Yeah, I moved it over because it doesn't need to be in there - ideally we'd have some kind of metadata construct that allows us to get this information. Either way, I'm saving that for a future refactoring of metadata (which I don't want to tackle)
Are the failing shared cluster tests somehow relevant to this PR? |
Nope, they have been failing for a while now and I haven't had a chance to dig into it and figure out what's causing them. |
Summary
Hydrators currently get the
UnitOfWork
injected directly. This leads to a circular dependency, as theDocumentManager
needs aHydratorFactory
, but theHydratorFactory
needs aUnitOfWork
instance which can't exist without aDocumentManager
. To resolve this,HydratorFactory
no longer takes aUnitOfWork
instance, and generated hydrators instead take theUnitOfWork
instance exposed by the document manager.This PR also moves a method from
UnitOfWork
to theDocumentManager
as it's not tied toUnitOfWork
.Note that this PR is only the first of a few refactorings necessary to properly decouple things from
UnitOfWork
, with the goal of havingUnitOfWork
represent a single set of persistable document changes. Removing the circular dependency also allows us to make hydrator factories configurable, which is important to leverage the new codec infrastructure in the PHP driver and thus speed up a lot of hydration operations.