[Form] Added an exception for invalid type services
Before the introduction of the FormRegistry, the getName() method was never used for types registered through the DI container. The FormRegistry now uses the getName() method and missconfigured services will trigger a notice. This was reported in FriendsOfSymfony/FOSCommentBundle#234
This commit is contained in:
parent
cf41bf8776
commit
6489a65960
@ -43,7 +43,13 @@ class DependencyInjectionExtension implements FormExtensionInterface
|
||||
throw new \InvalidArgumentException(sprintf('The field type "%s" is not registered with the service container.', $name));
|
||||
}
|
||||
|
||||
return $this->container->get($this->typeServiceIds[$name]);
|
||||
$type = $this->container->get($this->typeServiceIds[$name]);
|
||||
|
||||
if ($type->getName() !== $name) {
|
||||
throw new \InvalidArgumentException(sprintf('The type name specified for the service %s does not match the actual name', $this->typeServiceIds[$name]));
|
||||
}
|
||||
|
||||
return $type;
|
||||
}
|
||||
|
||||
public function hasType($name)
|
||||
|
Reference in New Issue
Block a user