You are here

class RoleAccessProvider in Role Access Control 8.2

Role Access Provider for Advanced Access.

Implements access control using reference fields with a target type of user_role.

View grants are given to each of the roles referenced from a entity. Update grants are determined by the update permissions.

Plugin annotation


@AccessProvider(
  id = "rac",
  label = @Translation("Role Access Control"),
  operations = {
    "view",
    "update",
    "delete",
  },
)

Hierarchy

  • class \Drupal\rac\Plugin\adva\AccessProvider\RoleAccessProvider extends \Drupal\adva\Plugin\adva\ReferenceAccessProvider

Expanded class hierarchy of RoleAccessProvider

File

src/Plugin/adva/AccessProvider/RoleAccessProvider.php, line 28

Namespace

Drupal\rac\Plugin\adva\AccessProvider
View source
class RoleAccessProvider extends ReferenceAccessProvider {

  /**
   * {@inheritdoc}
   */
  public static function getTargetType() {
    return "user_role";
  }

  /**
   * {@inheritdoc}
   */
  public function getAuthorizedEntityIds($operation, AccountInterface $account) {

    // A user should be authorized to access content for any roles they have.
    return $account
      ->getRoles();
  }

}

Members