Skip to content

[LiveComponent] Add support for interfaces while (de)hydrating a Doctrine entity #2834

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

Open
wants to merge 11 commits into
base: 2.x
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,21 @@ public function dehydrate(object $object): mixed

private function objectManagerFor(string $class): ?ObjectManager
{
if (!class_exists($class)) {
if (!interface_exist($class) && !class_exists($class)) {
return null;
}

// todo cache/warmup an array of classes that are "doctrine objects"
foreach ($this->managerRegistries as $registry) {
if ($om = $registry->getManagerForClass($class)) {
return self::ensureManagedObject($om, $class);
foreach($registry->getManagers() as $om) {
// this way, it resolves the interface
if ($om->getClassMetadata($class)) {
return self::ensureManagedObject($om, $class);
}
}
// if ($om = $registry->getManagerForClass($class)) {
// return self::ensureManagedObject($om, $class);
// }
}

return null;
Expand Down
Loading