【发布时间】:2015-08-09 08:55:03
【问题描述】:
根据 Symfony 从 3.0 版开始,The Symfony\Component\Security\Core\SecurityContext 将被删除。这已经在这里讨论过:Symfony 2 SecurityContext class deprecated
我的 symfony 报如下错误:
错误:Symfony\Component\Security\Core\SecurityContext 类是 自 2.6 版起已弃用,并将在 3.0 版中删除。采用 Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage 或 Symfony\Component\Security\Core\Authorization\AuthorizationChecker 而是。
我正在使用annotations 来管理我在 symfony 中的安全角色,例如
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security; // Security annotation bundle
/**
* @Route("/account/list", name="Account_list")
* @Security("has_role('ROLE_USER')")
*/
我应该如何切换到非折旧类?
使用错误中列出的任何一个类都会导致:
[语义错误] 方法中的注解“@Security” AppBundle\Controller\AccountController::listAction() 从来没有 进口的。您是否可能忘记为此添加“使用”声明 注解?在 /var/www/gra.investmentopportunities.pl/src/AppBundle/Controller/ (这是从 “/var/www/gra.investmentopportunities.pl/app/config/routing.yml”)。
【问题讨论】:
-
您仍应使用
Sensio\Bundle\FrameworkExtraBundle\Configuration\Security注释。您确定此弃用警告是由于注释引起的吗?自此提交以来,仅使用@Security标签就不会发出警告 - github.com/sensiolabs/SensioFrameworkExtraBundle/commit/…
标签: symfony