You are here

public function Security::trustedRoles in Security Review 8

Returns the trusted roles.

Return value

array Trusted roles' IDs.

1 call to Security::trustedRoles()
Security::trustedPermissions in src/Security.php
Returns the permission strings that trusted roles have.

File

src/Security.php, line 179

Class

Security
Provides frequently used security-related data.

Namespace

Drupal\security_review

Code

public function trustedRoles() {

  // Get the stored/default untrusted roles.
  $untrusted_roles = $this
    ->untrustedRoles();

  // Iterate through all the roles, and store which are not untrusted.
  $trusted = [];
  foreach (user_roles() as $role) {
    if (!in_array($role
      ->id(), $untrusted_roles)) {
      $trusted[] = $role
        ->id();
    }
  }

  // Return the trusted roles.
  return $trusted;
}