protected function UserCreationTrait::checkPermissions in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/simpletest/src/UserCreationTrait.php \Drupal\simpletest\UserCreationTrait::checkPermissions()
Checks whether a given list of permission names is valid.
Parameters
array $permissions: The permission names to check.
Return value
bool TRUE if the permissions are valid, FALSE otherwise.
1 call to UserCreationTrait::checkPermissions()
- UserCreationTrait::createRole in core/
modules/ simpletest/ src/ UserCreationTrait.php - Creates a role with specified permissions.
File
- core/
modules/ simpletest/ src/ UserCreationTrait.php, line 190 - 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 checkPermissions(array $permissions) {
$available = array_keys(\Drupal::service('user.permissions')
->getPermissions());
$valid = TRUE;
foreach ($permissions as $permission) {
if (!in_array($permission, $available)) {
$this
->fail(SafeMarkup::format('Invalid permission %permission.', array(
'%permission' => $permission,
)), 'Role');
$valid = FALSE;
}
}
return $valid;
}