Browse Source

[Doctrine] fixed Doctrine guesser when the object is a proxy and not an original entity instance

After this patch, the guesser is run for regular entity instances and proxy instances.
Fabien Potencier 14 năm trước cách đây
mục cha
commit
d3b78075f0

+ 4 - 1
src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php

@@ -16,6 +16,7 @@ use Symfony\Component\Form\Guess\Guess;
 use Symfony\Component\Form\Guess\TypeGuess;
 use Symfony\Component\Form\Guess\ValueGuess;
 use Symfony\Bridge\Doctrine\RegistryInterface;
+use Doctrine\ORM\Mapping\MappingException;
 
 class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
 {
@@ -122,8 +123,10 @@ class DoctrineOrmTypeGuesser implements FormTypeGuesserInterface
 
         $this->cache[$class] = null;
         foreach ($this->registry->getEntityManagers() as $name => $em) {
-            if (!$em->getConfiguration()->getMetadataDriverImpl()->isTransient($class)) {
+            try {
                 return $this->cache[$class] = array($em->getClassMetadata($class), $name);
+            } catch (MappingException $e) {
+                // not an entity or mapped super class
             }
         }
     }