You are here

public function GoogleAnalyticsQuery::addWhere in Google Analytics Reports 8.3

Add a filter string to the query.

Parameters

string $group: The filter group to add these to; groups are used to create AND/OR sections of the Google Analytics query. Groups cannot be nested. Use 0 as the default group. If the group does not yet exist it will be created as an AND group.

string $field: The name of the metric/dimension/field to check.

mixed $value: The value to test the field against. In most cases, this is a scalar.

string $operator: The comparison operator, such as =, <, or >=.

File

src/Plugin/views/query/GoogleAnalyticsQuery.php, line 218

Class

GoogleAnalyticsQuery
Defines a Views query class for Google Analytics Reports API.

Namespace

Drupal\google_analytics_reports\Plugin\views\query

Code

public function addWhere($group, $field, $value = NULL, $operator = NULL) {

  // Ensure all variants of 0 are actually 0. Thus '', 0 and NULL are all
  // the default group.
  if (empty($group)) {
    $group = 0;
  }

  // Check for a group.
  if (!isset($this->where[$group])) {
    $this
      ->setWhereGroup('AND', $group);
  }
  $this->where[$group]['conditions'][] = [
    'field' => $field,
    'value' => $value,
    'operator' => $operator,
  ];
}