diff --git a/src/lib/Form/Type/Content/BaseContentType.php b/src/lib/Form/Type/Content/BaseContentType.php index 515f848..aeeacdc 100644 --- a/src/lib/Form/Type/Content/BaseContentType.php +++ b/src/lib/Form/Type/Content/BaseContentType.php @@ -74,9 +74,7 @@ public function configureOptions(OptionsResolver $resolver) return $value; } - return $options['userUpdateStruct'] - ?? $options['userCreateStruct'] - ?? $options['contentUpdateStruct'] + return $options['contentUpdateStruct'] ?? $options['contentCreateStruct'] ?? null; }) @@ -91,8 +89,6 @@ public function configureOptions(OptionsResolver $resolver) 'null', ContentCreateStruct::class, ContentUpdateStruct::class, - UserCreateStruct::class, - UserUpdateStruct::class, ], ) ->setDeprecated( @@ -106,6 +102,19 @@ 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, ?UserCreateStruct $value): ?UserCreateStruct { + 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; + } ); } } diff --git a/src/lib/Form/Type/User/UserCreateType.php b/src/lib/Form/Type/User/UserCreateType.php index 2fd75bc..688fe1a 100644 --- a/src/lib/Form/Type/User/UserCreateType.php +++ b/src/lib/Form/Type/User/UserCreateType.php @@ -47,13 +47,12 @@ public function buildForm(FormBuilderInterface $builder, array $options) public function configureOptions(OptionsResolver $resolver): void { $resolver - ->setRequired('struct') ->setDefaults([ 'data_class' => UserCreateData::class, 'intent' => 'create', 'translation_domain' => 'ibexa_content_forms_user', ]) - ->setAllowedTypes('struct', UserCreateStruct::class); + ->setAllowedTypes('struct', ['null', UserCreateStruct::class]); } } diff --git a/src/lib/Form/Type/User/UserUpdateType.php b/src/lib/Form/Type/User/UserUpdateType.php index 3fcd4cf..c63804e 100644 --- a/src/lib/Form/Type/User/UserUpdateType.php +++ b/src/lib/Form/Type/User/UserUpdateType.php @@ -47,7 +47,6 @@ public function buildForm(FormBuilderInterface $builder, array $options) public function configureOptions(OptionsResolver $resolver): void { $resolver - ->setRequired('struct') ->setDefaults([ 'location' => null, 'content' => null, @@ -55,7 +54,7 @@ public function configureOptions(OptionsResolver $resolver): void 'intent' => 'update', 'translation_domain' => 'ibexa_content_forms_user', ]) - ->setAllowedTypes('struct', UserUpdateStruct::class); + ->setAllowedTypes('struct', ['null', UserUpdateStruct::class]); } }