Skip to content
Snippets Groups Projects
Commit dc99d818 authored by Liam Morland's avatar Liam Morland Committed by Kevin Paxman
Browse files

Revert "ISTWCMS-4631: Create UWService::userIsAdmin()"

This reverts commit 9b5d77cf.
parent fd842fd0
No related branches found
No related tags found
1 merge request!70ISTWCMS-4631: Toolbar permissions instead of role checks
......@@ -5,7 +5,6 @@ namespace Drupal\uw_cfg_common\Service;
use Drupal\Core\Database\Connection;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\node\NodeInterface;
use Drupal\simplify_menu\MenuItems;
......@@ -418,24 +417,4 @@ class UWService implements UWServiceInterface {
}
}
/**
* Determine whether the user is in an administrator group.
*
* @param \Drupal\Core\Session\AccountInterface $user
* The user object.
*
* @return bool
* TRUE if the user is in an administrator group, FALSE otherwise.
*/
public static function userIsAdmin(AccountInterface $user): bool {
$user_roles = $user->getRoles();
// Based on core/modules/user/src/AccountSettingsForm.php.
$admin_roles = \Drupal::service('entity_type.manager')->getStorage('user_role')->getQuery()
->condition('is_admin', TRUE)
->execute();
return (bool) array_intersect($user_roles, $admin_roles);
}
}
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