protected function UserCreationTrait::grantPermissions in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/simpletest/src/UserCreationTrait.php \Drupal\simpletest\UserCreationTrait::grantPermissions()
Grant permissions to a user role.
Parameters
\Drupal\user\RoleInterface $role: The ID of a user role to alter.
array $permissions: (optional) A list of permission names to grant.
1 call to UserCreationTrait::grantPermissions()
- UserCreationTrait::createRole in core/
modules/ simpletest/ src/ UserCreationTrait.php - Creates a role with specified permissions.
File
- core/
modules/ simpletest/ src/ UserCreationTrait.php, line 210 - Contains \Drupal\simpletest\UserCreationTrait.
Class
- UserCreationTrait
- Provides methods to create additional test users and switch the currently logged in one.
Namespace
Drupal\simpletestCode
protected function grantPermissions(RoleInterface $role, array $permissions) {
foreach ($permissions as $permission) {
$role
->grantPermission($permission);
}
$role
->trustData()
->save();
}