Получить все роли пользователей в Yii2

При изучении RBAC Yii2 у многих возникает вопрос, а как же получить все роли пользователей? Ответ довольно простой, скорее всего поэтому он быстро не гуглится. В итоге если у вас сам RBAC настроен верно, то список ролей можно получить так:

Yii::$app->getAuthManager()->getRoles()

или то же самое с помощью «магии»

Yii::$app->authManager->roles

Думаю еще одной интересной строчкой будет преобразование полученного массива в массив название роли -> описание, а сделать это можно так:

ArrayHelper::map(Yii::$app->authManager->roles,'name','description')
comments powered by HyperComments
yamanpluscasino
2026-06-25 14:09:39
The game variety here is insane. I spent hours exploring the slots and everything just works perfectly. Love <a href='https://yamanpluscasino.org' rel="nofollow ugc">yamanpluscasino</a>
bonoeuropacasino
2026-06-25 14:09:56
The bonuses here are actually generous and not just bait. It feels like a premium experience from the start at <a href='https://bonoeuropacasino.com' rel="nofollow ugc">bonoeuropacasino</a>
casinoperth
2026-06-25 14:10:13
Best spot for local vibes and great gaming options. Everything is very straightforward and professional. Highly recommend <a href='https://casinoperth.com' rel="nofollow ugc">casinoperth</a>
При копировании материалов обратная ссылка на play-stop.ru желательна обязательна!