我希望注入服务security.context&控制器中的service_container。有可能的 ?
这是我的控制器:
<?php
...
use Symfony\Component\Security\Core\SecurityContextInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
...
class ApiProtectedController extends Controller {
protected $container;
protected $securityContext;
function __construct(ContainerInterface $container, SecurityContextInterface $securityContext) {
$this->container = $container;
$this->securityContext = $securityContext;
}
...
}
我的服务声明
api_protected_controller:
class: MyProject\ApiBundle\Controller\ApiProtectedController
arguments: [@service_container, @security.context]
//here an example of something working fine
wsse.api.security.authentication.provider:
class: MyProject\ApiBundle\Security\Authentication\Provider\WsseProvider
arguments: ['', %kernel.cache_dir%/security/nonces, @service_container]
错误返回:
Catchable Fatal Error: Argument 1 passed to MyProject\ApiBundle\Controller\ApiProtectedController::__construct() must implement interface Symfony\Component\DependencyInjection\ContainerInterface, none given,
我的目标是通过securityContext
在我的控制器中输入wsseprovider
中注入的令牌,您认为这可能吗?