By jhedstrom on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
10.1.x
Introduced in version:
10.1.0
Issue links:
Description:
Drupal\Core\Session\AccountProxy and Drupal\Core\Session\UserSession now implement hasRole() method. It is possible to use the hasRole method on returns of type AccountInterface. For instance:
if (\Drupal::currentUser()->hasRole('foo')) {
...
}
AccountInterface do not define this method yet due to BC policies. The method definition will be added in Drupal 11.
See: #3228209: Move hasRole() method from UserInterface to AccountInterface.
Impacts:
Module developers