【发布时间】:2018-07-06 17:33:36
【问题描述】:
我是 Symfony 的新手,所以如果我问一个新手问题,我很抱歉,但是生产服务正在运行,现在都在下降,所以尝试热修复问题。
我需要为代码的特定部分添加安全性,并且这样做
我加了
if (true === $this->authorizationChecker->isGranted('ROLE_ADMIN'))
按照此处提供的文档在我的代码中:https://symfony.com/doc/2.8/security/securing_services.html
我的整个代码看起来像这样:
<?php
namespace SUP\SupervisorBundle\Controller;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
...
class AutoCompleteController extends Controller
{
protected $authorizationChecker;
public function __construct(AuthorizationCheckerInterface $authorizationChecker)
{
$this->authorizationChecker = $authorizationChecker;
}
但不知什么原因,我收到了Catchable Fatal Error: Argument 1 passed to SUP\SupervisorBundle\Controller\AutoCompleteController::__construct() must implement interface Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface, none given, called in sup/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Controller/ControllerResolver.php on line 186 and defined
我真的不明白出了什么问题,任何帮助将不胜感激。
【问题讨论】:
-
也许显示实现
AuthorizationCheckerInterface??? -
为什么投反对票?
标签: symfony symfony-2.8