0

I would like a list of all custom roles. Currently I am loading all of them using

$roles = $this->entityManager->getStorage('user_role')->loadMultiple();

but am wondering if there is any function that only brings the custom ones besides manually creating a static filter for the Anonymous, Authenticated and Administrator.

  • 3
    The Role entity doesn't really make any distinction. Looking at the roles in my own db (filter config table by name LIKE user.role%) the only potential contender I can see is that the three default ones have a dependency on _core, so you could check that via getDependencies, but that feels arguably flakier than a static filter to me. – stevekeiretsu Mar 16 '20 at 14:25
  • I see, thank you for clarifying that :-) – Lia Mar 18 '20 at 7:17
0

As @stevekeiretsu said in a comment ->

The Role entity doesn't really make any distinction. Looking at the roles in my own db (filter config table by name LIKE user.role%) the only potential contender I can see is that the three default ones have a dependency on _core, so you could check that via getDependencies, but that feels arguably flakier than a static filter to me.

So for Drupal 8 there is no function defined.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.