/** * {@inheritdoc} */ public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(['choices' => function (Options $options) { if (null !== $options['root']) { if (is_string($options['root'])) { $taxons = $this->taxonRepository->findChildrenByRootCode($options['root']); } else { $taxons = $this->taxonRepository->findChildren($options['root']); } } else { $taxons = $this->taxonRepository->findNodesTreeSorted(); } if (null !== $options['filter']) { $taxons = array_filter($taxons, $options['filter']); } return $taxons; }, 'choice_value' => 'id', 'choice_label' => 'name', 'choice_translation_domain' => false, 'root' => null, 'filter' => null])->setAllowedTypes('root', [TaxonInterface::class, 'string', 'null'])->setAllowedTypes('filter', ['callable', 'null']); }