Skip to content

Commit ed2b787

Browse files
committed
Code styling
1 parent e9afa14 commit ed2b787

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

src/LiveComponent/src/Hydration/DoctrineEntityHydrationExtension.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function dehydrate(object $object): mixed
6666
->getIdentifierValues($object);
6767

6868
// Dehydrate ID values in case they are other entities
69-
$id = array_map(fn($id) => \is_object($id) && $this->supports($id::class) ? $this->dehydrate($id) : $id, $id);
69+
$id = array_map(fn ($id) => \is_object($id) && $this->supports($id::class) ? $this->dehydrate($id) : $id, $id);
7070

7171
switch (\count($id)) {
7272
case 0:
@@ -88,27 +88,23 @@ private function objectManagerFor(string $class): ?ObjectManager
8888

8989
// todo cache/warmup an array of classes that are "doctrine objects"
9090
foreach ($this->managerRegistries as $registry) {
91-
9291
// The doctrine registry does not resolve aliased interface
9392
// if ($om = $registry->getManagerForClass($class)) {
9493
// return self::ensureManagedObject($om, $class);
9594
// }
96-
9795
foreach ($registry->getManagers() as $om) {
9896
// But we can resolve nicely by trying to ask each manager to get the metadata
9997
try {
100-
if ($om->getClassMetadata($class) !== null) {
98+
if (null !== $om->getClassMetadata($class)) {
10199
return self::ensureManagedObject($om, $class);
102100
}
103-
104101
} catch (MappingException $e) {
105102
// I did not find a nice way to check if it is because the class is really unknown
106103
// It is good to check for a specific exception ?
107104
// eg: \Doctrine\Persistence\Mapping\MappingException
108105
// Maybe not needed, because it does not failed even when the class does not exist at all
109-
// throw $e;
106+
// throw $e;
110107
}
111-
112108
}
113109
}
114110

src/LiveComponent/tests/Integration/Hydration/DoctrineEntityHydrationExtensionTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,14 @@ public function testForeignKeyId(): void
5555
self::assertSame($foreignKeyIdEntity, $extension->hydrate($dehydrated, ForeignKeyIdEntity::class));
5656
}
5757

58-
5958
public function testSupportInterface(): void
6059
{
6160
/** @var DoctrineEntityHydrationExtension $extension */
6261
$extension = self::getContainer()->get('ux.live_component.doctrine_entity_hydration_extension');
6362

64-
self::assertTrue($extension->supports(AliasedEntityInterface::class),"AliasedEntityInterface should be supported");
65-
self::assertTrue($extension->supports(AliasedEntity::class),"AliasedEntity should be supported");
66-
self::assertFalse($extension->supports('UnknownClass'),"UnknownClass should not be supported");
63+
self::assertTrue($extension->supports(AliasedEntityInterface::class),'AliasedEntityInterface should be supported');
64+
self::assertTrue($extension->supports(AliasedEntity::class),'AliasedEntity should be supported');
65+
self::assertFalse($extension->supports('UnknownClass'),'UnknownClass should not be supported');
6766
}
6867

6968
public function testHydrationFromInterface(): void

0 commit comments

Comments
 (0)