Skip to content

Commit 46e609b

Browse files
committed
Fix wrong merge
1 parent 5685496 commit 46e609b

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

@@ -339,22 +338,13 @@ public function configureOptions(OptionsResolver $resolver)
339338

340339
return $timeWidget;
341340
});
342-
foreach (['html5', 'format'] as $option) {
343-
$resolver->setDeprecated($option, static function (Options $options, $value) use ($option): string {
344-
try {
345-
$html5 = 'html5' === $option ? $value : $options['html5'];
346-
$format = 'format' === $option ? $value : $options['format'];
347-
} catch (OptionDefinitionException $e) {
348-
return '';
349-
}
350-
351-
if ($html5 && self::HTML5_FORMAT !== $format) {
352-
throw new LogicException(sprintf('Cannot use the "format" option of "%s" when the "html5" option is disabled.', self::class));
353-
}
354-
355-
return $html5;
356-
});
357-
}
341+
$resolver->setNormalizer('html5', function (Options $options, $html5) {
342+
if ($html5 && self::HTML5_FORMAT !== $options['format']) {
343+
throw new LogicException(sprintf('Cannot use the "format" option of "%s" when the "html5" option is enabled.', self::class));
344+
}
345+
346+
return $html5;
347+
});
358348
}
359349

360350
/**

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

@@ -324,23 +323,13 @@ public function configureOptions(OptionsResolver $resolver)
324323
$resolver->setAllowedTypes('days', 'array');
325324
$resolver->setAllowedTypes('input_format', 'string');
326325

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

341-
return $html5;
342-
});
343-
}
331+
return $html5;
332+
});
344333
}
345334

346335
/**

0 commit comments

Comments
 (0)