Skip to content
Snippets Groups Projects
Commit 4e64ee4d authored by John Voskuilen's avatar John Voskuilen
Browse files

Issue #3419771: Remove deprecated function user_roles_names()

parent c00a55a9
No related branches found
No related tags found
No related merge requests found
<?php <?php
use Drupal\Component\Utility\Html;
use Drupal\user\Entity\Role;
use Drupal\user\RoleInterface;
/** /**
* @file * @file
...@@ -307,17 +310,27 @@ function workflow_execute_transition(WorkflowTransitionInterface $transition, $f ...@@ -307,17 +310,27 @@ function workflow_execute_transition(WorkflowTransitionInterface $transition, $f
* Array of role names keyed by role ID, including the 'author' role. * Array of role names keyed by role ID, including the 'author' role.
*/ */
function workflow_get_user_role_names($permission) { function workflow_get_user_role_names($permission) {
static $roles = NULL; static $role_names = NULL;
if ($roles && isset($roles[$permission])) { if (isset($role_names[$permission])) {
return $roles[$permission]; return $role_names[$permission];
} }
// Copied from AccountForm::form(). // Copied from AccountForm::form().
$roles[$permission] = array_map(['\Drupal\Component\Utility\Html', 'escape'], if (version_compare(\Drupal::VERSION, '10.2', '>=')) {
[WORKFLOW_ROLE_AUTHOR_RID => '(' . t(WORKFLOW_ROLE_AUTHOR_NAME) . ')'] $roles = Role::loadMultiple();
+ user_role_names(FALSE, $permission)); $roles = array_map(fn(RoleInterface $role) => Html::escape($role->label()), $roles);
}
else {
// @phpstan-ignore-next-line
$roles = user_role_names(FALSE, $permission = NULL);
}
$author_label = '(' . t(WORKFLOW_ROLE_AUTHOR_NAME) . ')';
$author_roles = [WORKFLOW_ROLE_AUTHOR_RID => Html::escape($author_label)];
$role_names[$permission] = $author_roles + $roles;
return $roles[$permission]; return $role_names[$permission];
} }
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment