You are here

public function EntityOperation::buildOptionsForm in Views Entity Operation Access 8

Same name and namespace in other branches
  1. 2.x src/Plugin/views/access/EntityOperation.php \Drupal\veoa\Plugin\views\access\EntityOperation::buildOptionsForm()

Provide a form to edit options for this plugin.

Overrides PluginBase::buildOptionsForm

File

src/Plugin/views/access/EntityOperation.php, line 130

Class

EntityOperation
Access plugin checking if the current user can operate on an entity.

Namespace

Drupal\veoa\Plugin\views\access

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  parent::buildOptionsForm($form, $form_state);
  $form['parameter'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Parameter name'),
    '#default_value' => $this->options['parameter'],
    '#field_prefix' => '%',
    '#description' => $this
      ->t("The parameter found in the path. For example: '@parameter' found in path '@path'", [
      '@parameter' => '%node',
      '@path' => 'node/%node/edit',
    ]),
  ];
  $this->entityManager
    ->getEntityTypeLabels(TRUE);
  $form['entity_type'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Entity type'),
    '#default_value' => $this->options['entity_type'],
    '#options' => $this->entityManager
      ->getEntityTypeLabels(TRUE),
    '#empty_option' => $this
      ->t('- None -'),
    '#empty_value' => '',
  ];
  $form['operation'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Operation'),
    '#default_value' => $this->options['operation'],
    '#description' => $this
      ->t('Checks if the current user has access to execute an operation on an event. Common operations include: view, update, create, delete.'),
  ];
}