Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/4.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
ViniTou committed Jul 26, 2024
2 parents d322a1d + d1a733b commit 12c6521
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
17 changes: 9 additions & 8 deletions src/lib/Form/Type/Content/BaseContentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
})
Expand All @@ -91,8 +94,6 @@ public function configureOptions(OptionsResolver $resolver)
'null',
ContentCreateStruct::class,
ContentUpdateStruct::class,
UserCreateStruct::class,
UserUpdateStruct::class,
],
)
->setDeprecated(
Expand Down
3 changes: 1 addition & 2 deletions src/lib/Form/Type/User/UserCreateType.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,11 @@ 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]);
}
}
3 changes: 1 addition & 2 deletions src/lib/Form/Type/User/UserUpdateType.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,13 @@ public function buildForm(FormBuilderInterface $builder, array $options)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver
->setRequired('struct')
->setDefaults([
'location' => null,
'content' => null,
'data_class' => UserUpdateData::class,
'intent' => 'update',
'translation_domain' => 'ibexa_content_forms_user',
])
->setAllowedTypes('struct', UserUpdateStruct::class);
->setAllowedTypes('struct', ['null', UserUpdateStruct::class]);
}
}

0 comments on commit 12c6521

Please sign in to comment.