FIX [review] implement changes based on review

This commit is contained in:
2023-03-15 09:37:28 +01:00
parent 67e68ac149
commit 1a3d66213b
6 changed files with 49 additions and 25 deletions

View File

@@ -18,6 +18,7 @@ use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Serializer\SerializerInterface;
/**
@@ -27,12 +28,15 @@ class PickThirdpartyDynamicType extends AbstractType
{
private DenormalizerInterface $denormalizer;
private NormalizerInterface $normalizer;
private SerializerInterface $serializer;
public function __construct(DenormalizerInterface $denormalizer, SerializerInterface $serializer)
public function __construct(DenormalizerInterface $denormalizer, SerializerInterface $serializer, NormalizerInterface $normalizer)
{
$this->denormalizer = $denormalizer;
$this->serializer = $serializer;
$this->normalizer = $normalizer;
}
public function buildForm(FormBuilderInterface $builder, array $options)
@@ -45,7 +49,10 @@ class PickThirdpartyDynamicType extends AbstractType
$view->vars['multiple'] = $options['multiple'];
$view->vars['types'] = ['thirdparty'];
$view->vars['uniqid'] = uniqid('pick_user_dyn');
$view->vars['suggested'] = $this->serializer->serialize($options['suggested'], 'json', ['groups' => 'read']);
foreach ($options['suggested'] as $tp) {
$view->vars['suggested'][spl_object_hash($tp)] = $this->normalizer->normalize($tp, 'json', ['groups' => 'read']);
}
}
public function configureOptions(OptionsResolver $resolver)