Skip to content

Commit

Permalink
IBX-8711 added setting default for struct option in ContentFieldType
Browse files Browse the repository at this point in the history
  • Loading branch information
papcio122 committed Oct 1, 2024
1 parent 19ee7c7 commit 7a0287e
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/lib/Form/Type/Content/ContentFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Ibexa\ContentForms\FieldType\FieldTypeFormMapperDispatcherInterface;
use Ibexa\Contracts\ContentForms\Data\Content\FieldData;
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;
Expand All @@ -20,6 +21,7 @@
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;

class ContentFieldType extends AbstractType
Expand Down Expand Up @@ -48,6 +50,21 @@ public function configureOptions(OptionsResolver $resolver)
{
$resolver
->setRequired(['languageCode', 'mainLanguageCode', 'struct'])
->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;
})
->setDefaults([
'content' => null,
'location' => null,
Expand Down

0 comments on commit 7a0287e

Please sign in to comment.