PolicyService
class PolicyService (View source)
The policy service reads the policy configuration. The security advice asks this service which methods have to be intercepted by a security interceptor.
The access decision voters get the roles and privileges configured (in the security policy) for a specific method invocation from this service.
Properties
protected bool | $initialized | ||
protected ConfigurationManager | $configurationManager | ||
protected array | $policyConfiguration | ||
protected PrivilegeTarget[] | $privilegeTargets | ||
protected Role[] | $roles | ||
protected ObjectManagerInterface | $objectManager |
Methods
This object is created very early so we can't rely on AOP for the property injection
This object is created very early so we can't rely on AOP for the property injection
Parses the global policy configuration and initializes roles and privileges accordingly
Initialized all configured privilege targets from the policy definitions
Checks if a role exists
Returns an array of all configured roles
Returns all privileges of the given type
Returns all configured privilege targets
Returns the privilege target identified by the given string
Resets the PolicyService to behave transparently during functional testing.
Emits a signal when the policy configuration has been loaded
Emits a signal when roles have been initialized
Details
void
injectConfigurationManager(ConfigurationManager $configurationManager)
This object is created very early so we can't rely on AOP for the property injection
void
injectObjectManager(ObjectManagerInterface $objectManager)
This object is created very early so we can't rely on AOP for the property injection
protected void
initialize()
Parses the global policy configuration and initializes roles and privileges accordingly
protected void
initializePrivilegeTargets()
Initialized all configured privilege targets from the policy definitions
bool
hasRole(string $roleIdentifier)
Checks if a role exists
Role
getRole(string $roleIdentifier)
Returns a Role object configured in the PolicyService
array
getRoles(bool $includeAbstract = false)
Returns an array of all configured roles
array
getAllPrivilegesByType(string $type)
Returns all privileges of the given type
array
getPrivilegeTargets()
Returns all configured privilege targets
PrivilegeTarget|null
getPrivilegeTargetByIdentifier(string $privilegeTargetIdentifier)
Returns the privilege target identified by the given string
void
reset()
Resets the PolicyService to behave transparently during functional testing.
protected void
emitConfigurationLoaded(array $policyConfiguration)
Emits a signal when the policy configuration has been loaded
This signal can be used to add roles and/or privilegeTargets during runtime. In the slot make sure to receive the $policyConfiguration array by reference so you can alter it.
protected void
emitRolesInitialized(array $roles)
Emits a signal when roles have been initialized
This signal can be used to register roles during runtime. In the slot make sure to receive the $roles array by reference so you can alter it.