You are here

public function PermissionMatrix::__construct in Little helpers 7

File

src/c2c/PermissionMatrix.php, line 61

Class

PermissionMatrix

Namespace

Drupal\little_helpers\c2c

Code

public function __construct($db, $roles, $permissions = array()) {
  $this->db = $db;
  $this->roles = $roles;
  $this->perms = array();
  $modules = self::moduleList();
  foreach ($modules as $module => $module_name) {
    if ($defined_perms = module_invoke($module, 'permission')) {
      $perms = array();
      foreach ($defined_perms as $perm => $dontcare) {
        $this->width_perm = max(strlen($perm), $this->width_perm);
        $perms[] = $perm;
      }
      $this->perms[$module] = $perms;
    }
  }
  foreach ($roles as $r) {
    $this->width_role[] = max(strlen($r), 5);
  }
  $this->set = $permissions;
}