Skip to content

Commit

Permalink
Moved deprecation to default options callback
Browse files Browse the repository at this point in the history
  • Loading branch information
ViniTou committed Jul 10, 2024
1 parent 103b2c0 commit 5ebb8a8
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions src/lib/Form/Type/Content/BaseContentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
);
}
}
Expand Down

0 comments on commit 5ebb8a8

Please sign in to comment.