如何在Symfony 4中修复已弃用的用户? [英] How can I fix a deprecated user in Symfony 4?
本文介绍了如何在Symfony 4中修复已弃用的用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到以下错误消息:
不推荐使用的用户:自Symfony以来,不建议将配置选项直接传递给
构造函数4.2,请改用默认上下文
。
User Deprecated: Passing configuration options directly to the constructor is deprecated since Symfony 4.2, use the default context instead.
这是Symfony提供的用于跟踪问题的代码:
This is the code Symfony is giving as trace for the problem:
$serializer = new Serializer(array(new DateTimeNormalizer('d.m.Y'), new GetSetMethodNormalizer()), array('json' => new JsonEncoder()));
但是我不明白如何使用默认上下文
But I do not understand how to use a default context
推荐答案
您必须直接使用该服务。
You have to use directly the service.
class DefaultController extends AbstractController
{
public function index(SerializerInterface $serializer)
{
// keep reading for usage examples
}
}
https://symfony.com/doc/current/serializer.html
这篇关于如何在Symfony 4中修复已弃用的用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文