Merge branch '5.1'

* 5.1:
  Fix wrong merge
This commit is contained in:
Fabien Potencier 2020-09-27 06:23:47 +02:00
commit 2abc465335
2 changed files with 12 additions and 33 deletions

View File

@ -26,7 +26,6 @@ use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView; use Symfony\Component\Form\FormView;
use Symfony\Component\Form\ReversedTransformer; use Symfony\Component\Form\ReversedTransformer;
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;
use Symfony\Component\OptionsResolver\Exception\OptionDefinitionException;
use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
@ -344,22 +343,13 @@ class DateTimeType extends AbstractType
return $timeWidget; return $timeWidget;
}); });
foreach (['html5', 'format'] as $option) { $resolver->setNormalizer('html5', function (Options $options, $html5) {
$resolver->setDeprecated($option, static function (Options $options, $value) use ($option): string { if ($html5 && self::HTML5_FORMAT !== $options['format']) {
try { throw new LogicException(sprintf('Cannot use the "format" option of "%s" when the "html5" option is enabled.', self::class));
$html5 = 'html5' === $option ? $value : $options['html5']; }
$format = 'format' === $option ? $value : $options['format'];
} catch (OptionDefinitionException $e) {
return '';
}
if ($html5 && self::HTML5_FORMAT !== $format) { return $html5;
throw new LogicException(sprintf('Cannot use the "format" option of "%s" when the "html5" option is disabled.', self::class)); });
}
return $html5;
});
}
} }
/** /**

View File

@ -23,7 +23,6 @@ use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView; use Symfony\Component\Form\FormView;
use Symfony\Component\Form\ReversedTransformer; use Symfony\Component\Form\ReversedTransformer;
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;
use Symfony\Component\OptionsResolver\Exception\OptionDefinitionException;
use Symfony\Component\OptionsResolver\Options; use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
@ -329,23 +328,13 @@ class DateType extends AbstractType
$resolver->setAllowedTypes('days', 'array'); $resolver->setAllowedTypes('days', 'array');
$resolver->setAllowedTypes('input_format', 'string'); $resolver->setAllowedTypes('input_format', 'string');
foreach (['html5', 'widget', 'format'] as $option) { $resolver->setNormalizer('html5', function (Options $options, $html5) {
$resolver->setDeprecated($option, static function (Options $options, $value) use ($option): string { if ($html5 && 'single_text' === $options['widget'] && self::HTML5_FORMAT !== $options['format']) {
try { throw new LogicException(sprintf('Cannot use the "format" option of "%s" when the "html5" option is enabled.', self::class));
$html5 = 'html5' === $option ? $value : $options['html5']; }
$widget = 'widget' === $option ? $value : $options['widget'];
$format = 'format' === $option ? $value : $options['format'];
} catch (OptionDefinitionException $e) {
return '';
}
if ($html5 && 'single_text' === $widget && self::HTML5_FORMAT !== $format) { return $html5;
throw new LogicException(sprintf('Cannot use the "format" option of "%s" when the "html5" option is disabled.', self::class)); });
}
return $html5;
});
}
} }
/** /**