Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
By dawehner on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.0.x
Introduced in version:
8.0.0-beta8
Issue links:
Description:
Admin roles are now stored as part of the role entities itself, no longer as an extern variable.
Drupal 8 (before 8.0.x-beta4)
// Get the admin role.
$admin_role = \Drupal::config('user.settings')->get('admin_role');
// Change the admin role
\Drupal::configFactory()->getEditable('user.settings')->set('admin_role', 'my_new_administrator_role');
Drupal 8
// Get all admin roles.
$admin_roles = \Drupal::entityQuery('user_role')->condition('is_admin', TRUE)->execute();
// Set a specific role to be an admin role.
$role = \Drupal\user\Entity\Role::load('my_new_administrator_role')->set('is_admin', TRUE)->save();
Impacts:
Site builders, administrators, editors
Module developers