Beispiel #1
0
 /**
  * Setzt den Cache für die einzelnen Berechtigungen einer Rolle
  *
  * @param array $roles
  *
  * @return boolean
  */
 public function saveRulesCache(array $roles)
 {
     $privileges = [];
     foreach ($this->ruleRepository->getAllRulesByRoleIds($roles) as $rule) {
         $privilegeKey = strtolower($rule['key']);
         $privileges[$rule['module_name']][$privilegeKey] = ['id' => $rule['privilege_id'], 'description' => $rule['description'], 'permission' => $rule['permission'], 'access' => $this->hasAccess($rule, $privilegeKey)];
     }
     return $this->cache->save(static::CACHE_ID_RULES . implode(',', $roles), $privileges);
 }
Beispiel #2
0
 /**
  * Insert new acl user rules
  *
  * @param string $moduleName
  */
 protected function insertAclRules($moduleName)
 {
     $roles = $this->roleRepository->getAllRoles();
     $privileges = $this->privilegeRepository->getAllPrivilegeIds();
     $moduleId = $this->schemaHelper->getModuleId($moduleName);
     foreach ($roles as $role) {
         foreach ($privileges as $privilege) {
             $insertValues = ['id' => '', 'role_id' => $role['id'], 'module_id' => $moduleId, 'privilege_id' => $privilege['id'], 'permission' => $this->getDefaultAclRulePermission($role, $privilege)];
             $this->ruleRepository->insert($insertValues);
         }
     }
 }