You are here

public function SynonymsEntity::validateExposed in Synonyms 8

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

Validate the exposed handler form

Overrides HandlerBase::validateExposed

File

synonyms_views_filter/src/Plugin/views/filter/SynonymsEntity.php, line 149

Class

SynonymsEntity
Filter entity by its name or one of its synonyms.

Namespace

Drupal\synonyms_views_filter\Plugin\views\filter

Code

public function validateExposed(&$form, FormStateInterface $form_state) {
  parent::validateExposed($form, $form_state);
  $identifier = $this->options['expose']['identifier'];
  $target_ids = $form_state
    ->getValue($identifier);
  switch ($this->operator) {
    case 'IN':
      $target_ids = array_map(function ($item) {
        return $item['target_id'];
      }, $target_ids);
      break;
    case '=':
      $target_ids = $target_ids['target_id'];
      break;
  }
  $form_state
    ->setValue($identifier, $target_ids);
}