Преглед на файлове

[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 години
родител
ревизия
d3b78075f0
променени са 1 файла, в които са добавени 4 реда и са изтрити 1 реда
  1. 4 1
      src/Symfony/Bridge/Doctrine/Form/DoctrineOrmTypeGuesser.php

+ 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
             }
         }
     }