function Permissions::preRender
Same name in other branches
- 8.9.x core/modules/user/src/Plugin/views/field/Permissions.php \Drupal\user\Plugin\views\field\Permissions::preRender()
- 10 core/modules/user/src/Plugin/views/field/Permissions.php \Drupal\user\Plugin\views\field\Permissions::preRender()
- 11.x core/modules/user/src/Plugin/views/field/Permissions.php \Drupal\user\Plugin\views\field\Permissions::preRender()
Overrides FieldPluginBase::preRender
File
-
core/
modules/ user/ src/ Plugin/ views/ field/ Permissions.php, line 83
Class
- Permissions
- Field handler to provide a list of permissions.
Namespace
Drupal\user\Plugin\views\fieldCode
public function preRender(&$values) {
$this->items = [];
$permission_names = \Drupal::service('user.permissions')->getPermissions();
$rids = [];
foreach ($values as $result) {
$user_rids = $this->getEntity($result)
->getRoles();
$uid = $this->getValue($result);
foreach ($user_rids as $rid) {
$rids[$rid][] = $uid;
}
}
if ($rids) {
$roles = $this->roleStorage
->loadMultiple(array_keys($rids));
foreach ($rids as $rid => $role_uids) {
foreach ($roles[$rid]->getPermissions() as $permission) {
foreach ($role_uids as $uid) {
$this->items[$uid][$permission]['permission'] = $permission_names[$permission]['title'];
}
}
}
foreach ($this->items as &$permission) {
ksort($permission);
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.