public function __construct($tokenStorage, $authorizationChecker, $alwaysAuthenticate = false)
{
$oldSignature = $tokenStorage instanceof AuthenticationManagerInterface && $authorizationChecker instanceof AccessDecisionManagerInterface;
$newSignature = $tokenStorage instanceof TokenStorageInterface && $authorizationChecker instanceof AuthorizationCheckerInterface;
// confirm possible signatures
if (!$oldSignature && !$newSignature) {
throw new \BadMethodCallException('Unable to construct SecurityContext, please provide the correct arguments');
}
if ($oldSignature) {
// renamed for clarity
$authenticationManager = $tokenStorage;
$accessDecisionManager = $authorizationChecker;
$tokenStorage = new TokenStorage();
$authorizationChecker = new AuthorizationChecker($tokenStorage, $authenticationManager, $accessDecisionManager, $alwaysAuthenticate);
}
$this->tokenStorage = $tokenStorage;
$this->authorizationChecker = $authorizationChecker;
}