You are here

public function TermReference::acceptExposedInput in EntityFieldQuery Views Backend 8

Determines if the input from a filter should change the generated query.

Parameters

array $input: The exposed data for this view.

Return value

bool TRUE if the input for this filter should be included in the view query. FALSE otherwise.

Overrides InOperator::acceptExposedInput

File

src/Plugin/views/filter/TermReference.php, line 215
Contains \Drupal\efq_views\Plugin\views\filter\FieldInOperator.

Class

TermReference
Filter by term id.

Namespace

Drupal\efq_views\Plugin\views\filter

Code

public function acceptExposedInput($input) {
  if (empty($this->options['exposed'])) {
    return TRUE;
  }

  // If view is an attachment and is inheriting exposed filters, then assume
  // exposed input has already been validated
  if (!empty($this->view->is_attachment) && $this->view->display_handler
    ->uses_exposed()) {
    $this->validated_exposed_input = (array) $this->view->exposed_raw_input[$this->options['expose']['identifier']];
  }

  // If it's non-required and there's no value don't bother filtering.
  if (!$this->options['expose']['required'] && empty($this->validated_exposed_input)) {
    return FALSE;
  }
  $rc = parent::acceptExposedInput($input);
  if ($rc) {

    // If we have previously validated input, override.
    if (isset($this->validated_exposed_input)) {
      $this->value = $this->validated_exposed_input;
    }
  }
  return $rc;
}