Symfony2 API
Class

Symfony\Component\Security\Core\SecurityContext

class SecurityContext implements SecurityContextInterface

SecurityContext is the main entry point of the Security component.

It gives access to the token representing the current user authentication.

Methods

__construct(AuthenticationManagerInterface $authenticationManager, AccessDecisionManagerInterface $accessDecisionManager, Boolean $alwaysAuthenticate = false)

Constructor.

Boolean isGranted(mixed $attributes, mixed|null $object = null)

Checks if the attributes are granted against the current authentication token and optionally supplied object.

TokenInterface|null getToken()

Returns the current security token.

setToken(TokenInterface $token = null)

Sets the authentication token.

Details

at line 41
public __construct(AuthenticationManagerInterface $authenticationManager, AccessDecisionManagerInterface $accessDecisionManager, Boolean $alwaysAuthenticate = false)

Constructor.

Parameters

AuthenticationManagerInterface $authenticationManager An AuthenticationManager instance
AccessDecisionManagerInterface $accessDecisionManager An AccessDecisionManager instance
Boolean $alwaysAuthenticate

at line 58
final public Boolean isGranted(mixed $attributes, mixed|null $object = null)

Checks if the attributes are granted against the current authentication token and optionally supplied object.

Parameters

mixed $attributes
mixed|null $object

Return Value

Boolean

at line 80
public TokenInterface|null getToken()

Returns the current security token.

Return Value

TokenInterface|null A TokenInterface instance or null if no authentication information is available

at line 90
public setToken(TokenInterface $token = null)

Sets the authentication token.

Parameters

TokenInterface $token A TokenInterface token, or null if no further authentication information should be stored