You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<?phpnamespaceApp\Fixture\Factory;
useSymfony\Component\OptionsResolver\Options;
useSymfony\Component\OptionsResolver\OptionsResolver;
classProductExampleFactoryextendsSyliusProductExampleFactory
{
protectedfunctionconfigureOptions(OptionsResolver$resolver): void
{
parent::configureOptions($resolver);
$resolver// ...// Never run
->setDefault('product_options', function (Options$options): array {
$productOptions = $this->productOptionRepository->findAll();
return [$productOptions[rand(0, count($productOptions) - 1)]];
})
// Actually even you set the default value direct, the resolved value is still an empty array only// ->setDefault('product_options', ['Wow'])
;
}
}
I am not sure it is a SyliusFixtureBundle's bug or Symfony 4.3.3's bug
The text was updated successfully, but these errors were encountered:
The problem should be Symfony will resolve $option to [] for ArrayNode, so in public function create(array $options = []): ProductInterface, $options['product_options'] is [] already making setDefault callback will not run.
Symfony: 4.3.2
Sylius: 1.5.2
PHP: 7.3.7
Consider this fixture
In ProductExampleFactory
I am not sure it is a SyliusFixtureBundle's bug or Symfony 4.3.3's bug
The text was updated successfully, but these errors were encountered: