瀏覽代碼

Fixed Symfony deprecation warning on filter operator type (#4114)

François-Xavier de Guillebon 9 年之前
父節點
當前提交
310dbd36e1
共有 1 個文件被更改,包括 5 次插入2 次删除
  1. 5 2
      Form/Type/Filter/ChoiceType.php

+ 5 - 2
Form/Type/Filter/ChoiceType.php

@@ -86,7 +86,8 @@ class ChoiceType extends AbstractType
         }
 
         $operatorChoices = array();
-        if ($options['operator_type'] !== 'hidden') {
+        // NEXT_MAJOR: Remove first check (when requirement of Symfony is >= 2.8)
+        if ($options['operator_type'] !== 'hidden' && $options['operator_type'] !== 'Symfony\Component\Form\Extension\Core\Type\HiddenType') {
             $operatorChoices['choices'] = $choices;
 
             // NEXT_MAJOR: Remove this hack, when dropping support for symfony <2.7
@@ -119,7 +120,9 @@ class ChoiceType extends AbstractType
         $resolver->setDefaults(array(
             'field_type' => 'choice',
             'field_options' => array(),
-            'operator_type' => 'choice',
+            'operator_type' => method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')
+                ? 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'
+                : 'choice', // NEXT_MAJOR: Remove ternary (when requirement of Symfony is >= 2.8)
             'operator_options' => array(),
         ));
     }