diff --git a/Metadata/Driver/AnnotationDriver.php b/Metadata/Driver/AnnotationDriver.php index 008d1de..90cb80d 100644 --- a/Metadata/Driver/AnnotationDriver.php +++ b/Metadata/Driver/AnnotationDriver.php @@ -121,7 +121,7 @@ public function loadMetadataForClass(\ReflectionClass $class) // try to extract it from the class itself if (null === $alias) { $instance = unserialize(sprintf('O:%d:"%s":0:{}', strlen($className), $className)); - $alias = $instance->getName(); + $alias = method_exists($instance, 'getBlockPrefix') ? $instance->getBlockPrefix() : $instance->getName(); } $metadata->tags['form.type'][] = array( diff --git a/Tests/Metadata/Driver/Fixture/LoginType.php b/Tests/Metadata/Driver/Fixture/LoginType.php index 94c37a1..3654704 100644 --- a/Tests/Metadata/Driver/Fixture/LoginType.php +++ b/Tests/Metadata/Driver/Fixture/LoginType.php @@ -21,6 +21,11 @@ public function __construct(SecurityContext $context) } public function getName() + { + return $this->getBlockPrefix(); + } + + public function getBlockPrefix() { return 'login'; } diff --git a/Tests/Metadata/Driver/Fixture/SignUpType.php b/Tests/Metadata/Driver/Fixture/SignUpType.php index 6da3196..95c8cf2 100644 --- a/Tests/Metadata/Driver/Fixture/SignUpType.php +++ b/Tests/Metadata/Driver/Fixture/SignUpType.php @@ -13,6 +13,11 @@ class SignUpType extends AbstractType { public function getName() + { + return $this->getBlockPrefix(); + } + + public function getBlockPrefix() { return 'sign_up'; }