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
use Drupal\Component\Utility\Html;
use Drupal\user\Entity\Role;
use Drupal\user\RoleInterface;
/**
* @file
......@@ -307,17 +310,27 @@ function workflow_execute_transition(WorkflowTransitionInterface $transition, $f
* Array of role names keyed by role ID, including the 'author' role.
*/
function workflow_get_user_role_names($permission) {
static $roles = NULL;
if ($roles && isset($roles[$permission])) {
return $roles[$permission];
static $role_names = NULL;
if (isset($role_names[$permission])) {
return $role_names[$permission];
}
// Copied from AccountForm::form().
$roles[$permission] = array_map(['\Drupal\Component\Utility\Html', 'escape'],
[WORKFLOW_ROLE_AUTHOR_RID => '(' . t(WORKFLOW_ROLE_AUTHOR_NAME) . ')']
+ user_role_names(FALSE, $permission));
if (version_compare(\Drupal::VERSION, '10.2', '>=')) {
$roles = Role::loadMultiple();
$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.
Finish editing this message first!
Please register or to comment