You are here

public function CurrentUserOrPermission::buildOptionsForm in Ubercart 8.4

Provides the default form for setting options.

Overrides ArgumentValidatorPluginBase::buildOptionsForm

File

uc_order/src/Plugin/views/argument_validator/CurrentUserOrPermission.php, line 32

Class

CurrentUserOrPermission
Validate whether an argument is the current user or has a permission.

Namespace

Drupal\uc_order\Plugin\views\argument_validator

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  $options = [];
  $permissions = \Drupal::service('user.permissions')
    ->getPermissions();
  foreach ($permissions as $name => $permission) {
    $options[$permission['provider']][$name] = $permission['title'];
  }
  $form['perm'] = [
    '#type' => 'select',
    '#options' => $options,
    '#title' => $this
      ->t('Permission'),
    '#default_value' => $this->options['perm'],
    '#description' => $this
      ->t('Users with the selected permission flag will be able to bypass validation.'),
  ];
}