我正在将应用程序从 Symfony 4.4 迁移到 Symfony 5.4。在表单的情况下,我有一个表单,我在构造函数中传递了一个变量ContainerInterface $container
,以在小部件的配置中使用参数。在 5.4 版中,这给了我一个弃用警告:
从 symfony/dependency-injection 5.1 开始:“Symfony\Component\DependencyInjection\ContainerInterface”自动装配别名已被弃用。如果您想继续使用它,请在您的应用程序中明确定义它。它被“App\Form\BuscarAvanzadaNinhoType”服务引用。
我该如何解决?
class BuscarAvanzadaNinhoType extends AbstractType {
private $em;
private $security;
private $uuidEncoder;
private $container;
public function __construct(ManagerRegistry $em, Security $security, UuidEncoder $uuidEncoder, ContainerInterface $container) {
$this->em = $em;
$this->security = $security;
$this->uuidEncoder = $uuidEncoder;
$this->container = $container;
}
public function buildForm(FormBuilderInterface $builder, array $options) {
$builder
->add('otrosAspectos', Select2EntityType::class, array(
'class' => EtiquetaAspectoNinho::class,
'remote_route' => 'ninhos_encontrarEtiquetaAspectos',
'primary_key' => 'id',
'text_property' => 'text',
'multiple' => true,
'allow_clear' => false,
'delay' => 250,
'cache' => false,
'minimum_input_length' => 3,
'scroll' => true,
'page_limit' => $this->container->getParameter('limite_resultados_etiquetas'),
'language' => 'es',
'width' => '100%',
'placeholder' => '',
)
);
}
}