Initialize the default permissions for a role list.
Directories are excluded.

@param ResourceNode[] $nodes
@param Role[]         $roles
338696
public function initializePermissions(array $nodes, array $roles)
    {
        $this->om->startFlushSuite();

        foreach ($nodes as $node) {
            foreach ($roles as $role) {
                $type = $node->getResourceType();
                $this->editPerms(
                    $type->getDefaultMask(),
                    $role,
                    $node,
                    false
                );
            }
        }

        $this->om->endFlushSuite();
    }
858722
@POST
  @Path("/db/{authorizerName}/roles/{roleName}/permissions")
  @Produces(MediaType.APPLICATION_JSON)
  @Consumes(MediaType.APPLICATION_JSON)
  @ResourceFilters(BasicSecurityResourceFilter.class)
  public Response setRolePermissions(
      @Context HttpServletRequest req,
      @PathParam("authorizerName") final String authorizerName,
      @PathParam("roleName") String roleName,
      List<ResourceAction> permissions
  )
  {
    return resourceHandler.setRolePermissions(authorizerName, roleName, permissions);
  }
1351002
public void setRoles(List<NamedRoleInfo> roles) {
		this.roles = roles;
		List<AuthorizationInfo> authorizations = new ArrayList<AuthorizationInfo>();
		for (NamedRoleInfo role : roles) {
			authorizations.addAll(role.getAuthorizations());
		}
		super.setAuthorizations(authorizations);
	}
1086359
public function deleteRoles(array $ids): void
	{
		if ($this->isAjax()) {
			$roles = $this->orm->aclRoles->findById($ids);
			foreach ($roles as $role) {
				$this->orm->aclRoles->remove($role);
			}
			$this->orm->flush();
			$this['permissionsList']->reload();
		} else {
			$this->terminate();
		}
	}
654806
protected function _addRoles(array $roles) {
        foreach ($roles as $roleName => $properties) {
            // If the properties aren't set as an array, then we will consider
            // the value as the role ID.
            if (!is_array($properties)) {
                $properties = array('id' => $properties);
            }

            $id = $properties['id'];

            if (is_null($id) || empty($id)) {
                throw new Zend_Application_Resource_Exception(
                    sprintf(
                        $this->_missingPropertyMessage, 'ID', 'role', $roleName
                    )
                );
            }
            $this->_addRoleById($roles, $id);
        }
    }
85952
public function setRoles($roles)
    {
        if (!is_array($roles)) {
            $roles = [$roles];
        }

        $this->roles = $roles;

        return $this;
    }
783279
public static function addServerToRoles($server, array $roles)
    {
        foreach ($roles as $role) {
            self::$roles[$role][] = $server;
        }

    }
559985
public function getOneByRoleAndResource(Role $role, ResourceNode $node)
    {
        /** @var ResourceRights $resourceRights */
        $resourceRights = $this->rightsRepo->findOneBy(['resourceNode' => $node, 'role' => $role]);
        if ($resourceRights) {
            return $resourceRights;
        }

        $resourceRights = new ResourceRights();
        $resourceRights->setResourceNode($node);
        $resourceRights->setRole($role);

        return $resourceRights;
    }
566331
public function setWordpressRoles(array $roles, $prefix = 'ROLE_WP_')
    {
        foreach ($roles as $key => $role) {
            $roles[$key] = $prefix.strtoupper($role);
        }

        $this->setRoles($roles);

        return $this;
    }
639403
public function inherit($roles, $inherits) {

		if(true === is_string($roles)) {
			$roles = [$roles];
		}

		if(true === is_string($inherits)) {
			$inherits = [$inherits];
		}

		if(false === is_array($roles)) {
			return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string or array, "%s" given', __METHOD__, gettype($roles)), E_USER_ERROR);
		}

		if(false === is_array($inherits)) {
			return trigger_error(sprintf('Argument 2 passed to %s() must be of the type string or array, "%s" given', __METHOD__, gettype($inherits)), E_USER_ERROR);
		}

		foreach($inherits as $inherit) {

			if(true === isset($this -> permissions[$inherit])) {

				foreach($this -> permissions[$inherit] as $resource => $allowed) {

					foreach($roles as $role) {
						$this -> fill($role, $resource, $allowed);
					}
				}

			}
		}

		return $this; 
	}
481385
protected function isOne(array $roles)
    {
        foreach ($roles as $role) {
            if ($this->hasRole($role)) {
                return true;
            }
        }

        return false;
    }
191292
public void setPermissions(Permissions permissions) {
        if (this.permissions == permissions) {
            return;
        }

        this.removeChildObject("permissions");
        this.permissions = permissions;
        this.addChildObject("permissions", permissions);
    }
870424
private function assignPermissions(Collection $permissions) {
        $roles = Role::whereIn('id', $this->role_ids)->get();

        if ($roles && $permissions) {
            $permission_ids = $permissions->lists('id')->all();

            foreach ($roles as $role) {
                $role->permissions()->attach($permission_ids);
            }
        }
    }
1243768
public function setRoles($roles)
    {
        $allowedValues = $this->getRolesAllowableValues();
        if (!is_null($roles) && array_diff($roles, $allowedValues)) {
            throw new \InvalidArgumentException(
                sprintf(
                    "Invalid value for 'roles', must be one of '%s'",
                    implode("', '", $allowedValues)
                )
            );
        }
        $this->container['roles'] = $roles;

        return $this;
    }
1223098
public function storeRolePermission(Role $role, Permission $permission)
    {
        $this->getTable()->insert([
            'role' => $role->getRoleName(),
            'type' => $permission->getType(),
            'action' => $permission->getAction(),
            'resource_type' => $permission->getResourceType(),
            'resource_id' => $permission->getResourceId(),
        ]);

        $this->resetPermissionsCacheForRole($role);
    }
605882
public void setRoles(java.util.Collection<PermissionInfo> roles) {
        if (roles == null) {
            this.roles = null;
            return;
        }

        this.roles = new java.util.ArrayList<PermissionInfo>(roles);
    }
150970
public function setRoles(array $roles) {
		
		$this->roles = [];
		
		foreach($roles as $role) {

			if(!$role instanceof Role) {
				throw new \InvalidArgumentException('Role is not a role instance.');
			}
			if(array_key_exists($role->getRoleName(), $this->roles)) {
				throw new \InvalidArgumentException(sprintf("Role '%s' defined twice.", $role->getRoleName()));
			}

			$this->roles[$role->getRoleName()] = $role;

		}

		return $this;
	}