if (!
isset($rid)) { $rid =
strtolower($this->
randomMachineName(8
));
} // Generate a random label.
if (!
isset($name)) { // In the role UI role names are trimmed and random string can start or
// end with a space.
$name =
trim($this->
randomString(8
));
} // Check the all the permissions strings are valid.
if (!
$this->
checkPermissions($permissions)) { return FALSE;
} // Create new role.
$role = Role::
create([ 'id' =>
$rid,
'label' =>
$name,
]);
if (isset($weight)) { $role->
set('weight',
$weight);
}