You are here

public function CurrentUser::buildOptionsForm in Commerce Core 8.2

Provides the default form for setting options.

Overrides ArgumentValidatorPluginBase::buildOptionsForm

File

src/Plugin/views/argument_validator/CurrentUser.php, line 113

Class

CurrentUser
Validates whether the argument matches the current user.

Namespace

Drupal\commerce\Plugin\views\argument_validator

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);

  // Build the list of all permissions grouped by module.
  $permissions = [];
  foreach ($this->permissionHandler
    ->getPermissions() as $permission => $permission_item) {
    $provider = $permission_item['provider'];
    $display_name = $this->moduleHandler
      ->getName($provider);
    $permissions[$display_name][$permission] = Html::escape($permission_item['title']);
  }
  $form['admin_permission'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Admin permission'),
    '#description' => $this
      ->t('Allows the current user to access the view even if the argument is a different user.'),
    '#options' => $permissions,
    '#empty_value' => '',
    '#default_value' => $this->options['admin_permission'],
  ];
}