Skip to content

Commit 2abc465

Browse files
committed
Merge branch '5.1'
* 5.1: Fix wrong merge
2 parents 6ca9225 + 46e609b commit 2abc465

File tree

2 files changed

+13
-34
lines changed

2 files changed

+13
-34
lines changed

src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
use Symfony\Component\Form\FormView;
2727
use Symfony\Component\Form\ReversedTransformer;
2828
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;
29-
use Symfony\Component\OptionsResolver\Exception\OptionDefinitionException;
3029
use Symfony\Component\OptionsResolver\Options;
3130
use Symfony\Component\OptionsResolver\OptionsResolver;
3231

@@ -344,22 +343,13 @@ public function configureOptions(OptionsResolver $resolver)
344343

345344
return $timeWidget;
346345
});
347-
foreach (['html5', 'format'] as $option) {
348-
$resolver->setDeprecated($option, static function (Options $options, $value) use ($option): string {
349-
try {
350-
$html5 = 'html5' === $option ? $value : $options['html5'];
351-
$format = 'format' === $option ? $value : $options['format'];
352-
} catch (OptionDefinitionException $e) {
353-
return '';
354-
}
355-
356-
if ($html5 && self::HTML5_FORMAT !== $format) {
357-
throw new LogicException(sprintf('Cannot use the "format" option of "%s" when the "html5" option is disabled.', self::class));
358-
}
359-
360-
return $html5;
361-
});
362-
}
346+
$resolver->setNormalizer('html5', function (Options $options, $html5) {
347+
if ($html5 && self::HTML5_FORMAT !== $options['format']) {
348+
throw new LogicException(sprintf('Cannot use the "format" option of "%s" when the "html5" option is enabled.', self::class));
349+
}
350+
351+
return $html5;
352+
});
363353
}
364354

365355
/**

src/Symfony/Component/Form/Extension/Core/Type/DateType.php

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
use Symfony\Component\Form\FormView;
2424
use Symfony\Component\Form\ReversedTransformer;
2525
use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException;
26-
use Symfony\Component\OptionsResolver\Exception\OptionDefinitionException;
2726
use Symfony\Component\OptionsResolver\Options;
2827
use Symfony\Component\OptionsResolver\OptionsResolver;
2928

@@ -329,23 +328,13 @@ public function configureOptions(OptionsResolver $resolver)
329328
$resolver->setAllowedTypes('days', 'array');
330329
$resolver->setAllowedTypes('input_format', 'string');
331330

332-
foreach (['html5', 'widget', 'format'] as $option) {
333-
$resolver->setDeprecated($option, static function (Options $options, $value) use ($option): string {
334-
try {
335-
$html5 = 'html5' === $option ? $value : $options['html5'];
336-
$widget = 'widget' === $option ? $value : $options['widget'];
337-
$format = 'format' === $option ? $value : $options['format'];
338-
} catch (OptionDefinitionException $e) {
339-
return '';
340-
}
341-
342-
if ($html5 && 'single_text' === $widget && self::HTML5_FORMAT !== $format) {
343-
throw new LogicException(sprintf('Cannot use the "format" option of "%s" when the "html5" option is disabled.', self::class));
344-
}
331+
$resolver->setNormalizer('html5', function (Options $options, $html5) {
332+
if ($html5 && 'single_text' === $options['widget'] && self::HTML5_FORMAT !== $options['format']) {
333+
throw new LogicException(sprintf('Cannot use the "format" option of "%s" when the "html5" option is enabled.', self::class));
334+
}
345335

346-
return $html5;
347-
});
348-
}
336+
return $html5;
337+
});
349338
}
350339

351340
/**

0 commit comments

Comments
 (0)