8000 [DoctrineBridge] Fixed: Exception is thrown if the entity class is no… · symfony/symfony@99321cb · GitHub
[go: up one dir, main page]

Skip to content

Commit 99321cb

Browse files
committed
[DoctrineBridge] Fixed: Exception is thrown if the entity class is not known to Doctrine
1 parent 889bd2e commit 99321cb

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/Symfony/Bridge/Doctrine/Form/Type/DoctrineType.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bridge\Doctrine\Form\Type;
1313

1414
use Doctrine\Common\Persistence\ManagerRegistry;
15+
use Symfony\Component\Form\Exception\FormException;
1516
use Doctrine\Common\Persistence\ObjectManager;
1617
use Symfony\Component\Form\FormBuilderInterface;
1718
use Symfony\Bridge\Doctrine\Form\ChoiceList\EntityChoiceList;
@@ -130,7 +131,17 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
130131
return $registry->getManager($em);
131132
}
132133

133-
return $registry->getManagerForClass($options['class']);
134+
$em = $registry->getManagerForClass($options['class']);
135+
136+
if (null === $em) {
137+
throw new FormException(sprintf(
138+
'Class "%s" seems not to be a managed Doctrine entity. ' .
139+
'Did you forget to map it?',
140+
$options['class']
141+
));
142+
}
143+
144+
return $em;
134145
};
135146

136147
$resolver->setDefaults(array(

0 commit comments

Comments
 (0)
0