A
A
Alexey Pavlov2015-03-31 12:11:06
symfony
Alexey Pavlov, 2015-03-31 12:11:06

Why is the OptionsResolverInterface interface deprecated in the Symfony Form component?

I noticed a long time ago that the OptionsResolverInterface interface in the Form component is marked as deprecated. But even in the official documentation , it is used when creating a form class:

use Symfony\Component\OptionsResolver\OptionsResolverInterface;

public function setDefaultOptions(OptionsResolverInterface $resolver)
{
    $resolver->setDefaults(array(
        'data_class' => 'AppBundle\Entity\Task',
    ));
}

Is there an updated analogue to replace the OptionsResolverInterface? Or else how to set default values ​​in the right way?
The description of the interface Symfony\Component\OptionsResolver\OptionsResolverInterface says:
@deprecated Deprecated since Symfony 2.6, to be removed in Symfony 3.0.
Use {@link OptionsResolver} instead.

The OptionsResolver class is a class that implements the same OptionsResolverInterface interface. But if you put its use in the setDefaultOptions method, then it will not pass the argument type check.
It turns out, while (in version before 3.0) it is necessary to continue to use the deprecated OptionsResolverInterface?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2015-03-31
@lexxpavlov

For example: symfony.com/doc/master/book/forms.html#validation-... New configureOptions method since 2.7
But for now, you can use the old version if you don't mind crossed words in the same storm

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question