public function FarmRoleStorage::isPermissionInRoles in farmOS 2.x
Returns whether a permission is in one of the passed in roles.
Parameters
string $permission: The permission.
array $rids: The list of role IDs to check.
Return value
bool TRUE is the permission is in at least one of the roles. FALSE otherwise.
Overrides RoleStorage::isPermissionInRoles
File
- modules/
core/ role/ src/ FarmRoleStorage.php, line 68
Class
- FarmRoleStorage
- FarmRoleStorage.
Namespace
Drupal\farm_roleCode
public function isPermissionInRoles($permission, array $rids) {
// Check if the permission is defined directly on the role.
$has_permission = parent::isPermissionInRoles($permission, $rids);
// Else check if the permission is included via farm_role rules.
if (!$has_permission) {
foreach ($this
->loadMultiple($rids) as $role) {
/** @var \Drupal\user\RoleInterface $role */
$has_permission = $this->managedRolePermissionsManager
->isPermissionInRole($permission, $role);
if ($has_permission) {
break;
}
}
}
return $has_permission;
}