From 6489a65960a05b6a5a4f5c5074b941a6765c6381 Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Sat, 14 Jul 2012 13:04:03 +0200 Subject: [PATCH] [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 --- .../DependencyInjection/DependencyInjectionExtension.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php b/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php index 2b2b1a3d59..efc5fdf75b 100644 --- a/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php +++ b/src/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php @@ -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)