From 7936c7c211b73e62355cc94854a37a6b865f37ef Mon Sep 17 00:00:00 2001 From: Piotr Szymaszek Date: Thu, 8 Jun 2017 15:23:15 +0200 Subject: [PATCH] Use class metadata to extract entity ID --- .../DoctrineExtensions/Mapping/Event/Adapter/ORM.php | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/lib/FSi/DoctrineExtensions/Mapping/Event/Adapter/ORM.php b/lib/FSi/DoctrineExtensions/Mapping/Event/Adapter/ORM.php index 7343428..4ea39b9 100644 --- a/lib/FSi/DoctrineExtensions/Mapping/Event/Adapter/ORM.php +++ b/lib/FSi/DoctrineExtensions/Mapping/Event/Adapter/ORM.php @@ -64,15 +64,7 @@ public function extractIdentifier(EntityManager $em, $object, $single = true) if ($object instanceof Proxy) { $id = $em->getUnitOfWork()->getEntityIdentifier($object); } else { - $meta = $em->getClassMetadata(get_class($object)); - $id = []; - foreach ($meta->identifier as $name) { - $id[$name] = ReflectionProperty::factory($meta->name, $name)->getValue($object); - // return null if one of identifiers is missing - if (!$id[$name]) { - return null; - } - } + $id = $em->getClassMetadata(get_class($object))->getIdentifierValues($object); } if ($single) {