浏览代码

use class names for types in 2.8 too

This should generate less deprecation notices.
Grégoire Paris 9 年之前
父节点
当前提交
9f15208637

+ 4 - 1
Form/Extension/Field/Type/FormTypeFieldExtension.php

@@ -153,7 +153,10 @@ class FormTypeFieldExtension extends AbstractTypeExtension
      */
     public function getExtendedType()
     {
-        return 'form';
+        return
+            method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix') ?
+            'Symfony\Component\Form\Extension\Core\Type\FormType' :
+            'form';
     }
 
     /**

+ 4 - 1
Form/Type/CollectionType.php

@@ -26,7 +26,10 @@ class CollectionType extends AbstractType
      */
     public function getParent()
     {
-        return 'collection';
+        return
+            method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix') ?
+            'Symfony\Component\Form\Extension\Core\Type\CollectionType' :
+            'collection';
     }
 
     /**

+ 6 - 1
Tests/Form/Extension/Field/Type/FormTypeFieldExtensionTest.php

@@ -23,7 +23,12 @@ class FormTypeFieldExtensionTest extends \PHPUnit_Framework_TestCase
     {
         $extension = new FormTypeFieldExtension();
 
-        $this->assertSame('form', $extension->getExtendedType());
+        $this->assertSame(
+            method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix') ?
+            'Symfony\Component\Form\Extension\Core\Type\FormType' :
+            'form',
+            $extension->getExtendedType()
+        );
     }
 
     public function testDefaultOptions()