You are here

public function GoogleAnalyticsNumeric::acceptExposedInput in Google Analytics Reports 8.3

Do some minor translation of the exposed input.

Overrides FilterPluginBase::acceptExposedInput

File

src/Plugin/views/filter/GoogleAnalyticsNumeric.php, line 207

Class

GoogleAnalyticsNumeric
Simple filter to handle numerics for Google Analytics.

Namespace

Drupal\google_analytics_reports\Plugin\views\filter

Code

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

  // Rewrite the input value so that it's in the correct format so that
  // the parent gets the right data.
  if (!empty($this->options['expose']['identifier'])) {
    $value =& $input[$this->options['expose']['identifier']];
    if (!is_array($value)) {
      $value = [
        'value' => $value,
      ];
    }
  }
  $rc = parent::acceptExposedInput($input);
  if (empty($this->options['expose']['required'])) {

    // We have to do some of our own checking for non-required filters.
    $info = $this
      ->operators();
    if (!empty($info[$this->operator]['values'])) {
      switch ($info[$this->operator]['values']) {
        case 1:
          if ($value['value'] === '') {
            return FALSE;
          }
          break;
        case 2:
          if ($value['min'] === '' && $value['max'] === '') {
            return FALSE;
          }
          break;
      }
    }
  }
  return $rc;
}