From 5ebb8a85681d29d1ae8457847b10008c8bdb809c Mon Sep 17 00:00:00 2001 From: Dawid Parafinski Date: Wed, 10 Jul 2024 08:54:22 +0200 Subject: [PATCH] Moved deprecation to default options callback --- src/lib/Form/Type/Content/BaseContentType.php | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/lib/Form/Type/Content/BaseContentType.php b/src/lib/Form/Type/Content/BaseContentType.php index 9dd6242..84c5a01 100644 --- a/src/lib/Form/Type/Content/BaseContentType.php +++ b/src/lib/Form/Type/Content/BaseContentType.php @@ -68,11 +68,17 @@ public function configureOptions(OptionsResolver $resolver) { $resolver ->setRequired(['languageCode', 'mainLanguageCode', 'struct']) - ->setDefault('struct', static function (Options $options, $value) { + ->setDefault('struct', static function (Options $options, ?ContentStruct $value) { if ($value !== null) { return $value; } + trigger_deprecation( + 'ibexa/content-forms', + 'v4.6', + 'The option "struct" with null value is deprecated and will be required in v5.0.' + ); + return $options['contentUpdateStruct'] ?? $options['contentCreateStruct'] ?? null; @@ -101,20 +107,6 @@ public function configureOptions(OptionsResolver $resolver) 'ibexa/content-forms', 'v4.6.4', 'The option "%name%" is deprecated, use "struct" instead.' - ) - ->setNormalizer( - 'struct', - static function (Options $options, ?ContentStruct $value): ?ContentStruct { - if ($value === null) { - trigger_deprecation( - 'ibexa/content-forms', - 'v4.6', - 'The option "struct" with null value is deprecated and will be required in v5.0.' - ); - } - - return $value; - } ); } }