Skip to main content
Version: 1.4

Authorization Service

Usage

The Authorization service can be retrieved from the service manager using the name LmcRbac\Service\AuthorizationServiceInterface and injected into your code:

<?php
/** @var \Psr\Container\ContainerInterface $container */
$authorizationService = $container->get(LmcRbac\Service\AuthorizationServiceInterface::class);

Reference

LmcRbac\Service\AuthorizationServiceInterface defines the following method:

  • isGranted(?IdentityInterface $identity, string $permission, $context = null): bool
ParameterDescription
$identityThe identity whose roles to checks.
If $identity is null, then the guest is used.
The guest role is definable via configuration and defaults to 'guest'.
$permissionThe permission to check against
$contextA context that will be passed to dynamic assertions that are defined for the permission

More on dynamic assertions can be found in the Assertions section.

More on the guest role can be found in the Configuration section.