Deprecated user_role_names in drupal:10.2.0 and is removed from drupal:11.0.0

Created on 3 January 2024, 12 months ago
Updated 17 April 2024, 8 months ago

Problem/Motivation

 * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use
 *   \Drupal\user\Entity\Role::loadMultiple() and, if necessary, an inline
 *   implementation instead.
 *
 * @see https://www.drupal.org/node/3349759

Proposed resolution

Use this code instead

$roles = array_keys(array_filter(Role::loadMultiple(), fn(RoleInterface $role) => $role->hasPermission($permission)));

🐛 Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

🇯🇴Jordan Ahmad Khader

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024