function Permission::buildOptionsForm
Same name in other branches
- 9 core/modules/user/src/Plugin/views/access/Permission.php \Drupal\user\Plugin\views\access\Permission::buildOptionsForm()
- 10 core/modules/user/src/Plugin/views/access/Permission.php \Drupal\user\Plugin\views\access\Permission::buildOptionsForm()
- 11.x core/modules/user/src/Plugin/views/access/Permission.php \Drupal\user\Plugin\views\access\Permission::buildOptionsForm()
Overrides PluginBase::buildOptionsForm
File
-
core/
modules/ user/ src/ Plugin/ views/ access/ Permission.php, line 110
Class
- Permission
- Access plugin that provides permission-based access control.
Namespace
Drupal\user\Plugin\views\accessCode
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
// Get list of permissions
$perms = [];
$permissions = $this->permissionHandler
->getPermissions();
foreach ($permissions as $perm => $perm_item) {
$provider = $perm_item['provider'];
$display_name = $this->moduleHandler
->getName($provider);
$perms[$display_name][$perm] = strip_tags($perm_item['title']);
}
$form['perm'] = [
'#type' => 'select',
'#options' => $perms,
'#title' => $this->t('Permission'),
'#default_value' => $this->options['perm'],
'#description' => $this->t('Only users with the selected permission flag will be able to access this display.'),
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.