You are here

public function KeywordId::validateExposed in Bibliography & Citation 8

Same name and namespace in other branches
  1. 2.0.x modules/bibcite_entity/src/Plugin/views/filter/KeywordId.php \Drupal\bibcite_entity\Plugin\views\filter\KeywordId::validateExposed()

Validate the exposed handler form

Overrides HandlerBase::validateExposed

File

modules/bibcite_entity/src/Plugin/views/filter/KeywordId.php, line 84

Class

KeywordId
Filter handler for keywords.

Namespace

Drupal\bibcite_entity\Plugin\views\filter

Code

public function validateExposed(&$form, FormStateInterface $form_state) {
  if (empty($this->options['exposed'])) {
    return;
  }
  if (empty($this->options['expose']['identifier'])) {
    return;
  }
  $identifier = $this->options['expose']['identifier'];
  $input = $form_state
    ->getValue($identifier);
  if ($this->options['is_grouped'] && isset($this->options['group_info']['group_items'][$input])) {
    $this->operator = $this->options['group_info']['group_items'][$input]['operator'];
    $input = $this->options['group_info']['group_items'][$input]['value'];
  }
  $ids = [];
  $values = $form_state
    ->getValue($identifier);
  if ($values && (!$this->options['is_grouped'] || $this->options['is_grouped'] && $input != 'All')) {
    foreach ($values as $value) {
      $ids[] = $value['target_id'];
    }
  }
  if ($ids) {
    $this->validatedExposedInput = $ids;
  }
}