improve FormType::getType exception message details
This commit is contained in:
parent
39bcfd4702
commit
945f23602b
@ -84,11 +84,14 @@ class FormRegistry implements FormRegistryInterface
|
||||
|
||||
if (!$type) {
|
||||
// Support fully-qualified class names
|
||||
if (class_exists($name) && in_array('Symfony\Component\Form\FormTypeInterface', class_implements($name))) {
|
||||
$type = new $name();
|
||||
} else {
|
||||
throw new InvalidArgumentException(sprintf('Could not load type "%s"', $name));
|
||||
if (!class_exists($name)) {
|
||||
throw new InvalidArgumentException(sprintf('Could not load type "%s": class does not exist.', $name));
|
||||
}
|
||||
if (!in_array(FormTypeInterface::class, class_implements($name))) {
|
||||
throw new InvalidArgumentException(sprintf('Could not load type "%s": class does not implement "%s".', $name, FormTypeInterface::class));
|
||||
}
|
||||
|
||||
$type = new $name();
|
||||
}
|
||||
|
||||
$this->resolveAndAddType($type);
|
||||
|
Reference in New Issue
Block a user