如何在symfony2中使用AuthorizationChecker类而不是SecurityContext

时间:2016-01-05 14:25:03

标签: symfony mpdf

我正在使用mpadf&使用symfony 2.7版本

但是这个错误抛出了

  

Symfony \ Component \ Security \ Core \ SecurityContext类是   自2.6版以来已弃用,将在3.0中删除。使用   Symfony的\分量\安全\核心\认证\令牌\存储\ TokenStorage   或Symfony \ Component \ Security \ Core \ Authorization \ AuthorizationChecker   代替。

有人有想法吗?

1 个答案:

答案 0 :(得分:3)

你必须改变:

$user = $this->get('security.token_storage')->getToken()->getUser();

为:

Symfony\Component\Security\Core\SecurityContext

并删除使用部分:

#logodiv

您可以在Symfony博客页面找到更多信息:http://symfony.com/blog/new-in-symfony-2-6-security-component-improvements