diff --git a/src/lib/Form/Type/Content/BaseContentType.php b/src/lib/Form/Type/Content/BaseContentType.php index 515f848..84c5a01 100644 --- a/src/lib/Form/Type/Content/BaseContentType.php +++ b/src/lib/Form/Type/Content/BaseContentType.php @@ -9,9 +9,8 @@ namespace Ibexa\ContentForms\Form\Type\Content; use Ibexa\Contracts\Core\Repository\Values\Content\ContentCreateStruct; +use Ibexa\Contracts\Core\Repository\Values\Content\ContentStruct; use Ibexa\Contracts\Core\Repository\Values\Content\ContentUpdateStruct; -use Ibexa\Contracts\Core\Repository\Values\User\UserCreateStruct; -use Ibexa\Contracts\Core\Repository\Values\User\UserUpdateStruct; use JMS\TranslationBundle\Annotation\Desc; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\HiddenType; @@ -69,14 +68,18 @@ 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; } - return $options['userUpdateStruct'] - ?? $options['userCreateStruct'] - ?? $options['contentUpdateStruct'] + 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; }) @@ -91,8 +94,6 @@ public function configureOptions(OptionsResolver $resolver) 'null', ContentCreateStruct::class, ContentUpdateStruct::class, - UserCreateStruct::class, - UserUpdateStruct::class, ], ) ->setDeprecated( 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]); } }