You are here

protected function GoogleAnalyticsCounterFeed::sanitizeReport in Google Analytics Counter 8.3

Sanitize report data.

1 call to GoogleAnalyticsCounterFeed::sanitizeReport()
GoogleAnalyticsCounterFeed::queryReportFeed in src/GoogleAnalyticsCounterFeed.php
Query and sanitize report data.

File

src/GoogleAnalyticsCounterFeed.php, line 627

Class

GoogleAnalyticsCounterFeed
Authorize access and request data from Google Analytics Core Reporting API.

Namespace

Drupal\google_analytics_counter

Code

protected function sanitizeReport() {

  // Named keys for report values.
  $this->results->rawRows = isset($this->results->rows) ? $this->results->rows : [];
  $this->results->rows = [];
  foreach ($this->results->rawRows as $row_key => $row_value) {
    foreach ($row_value as $item_key => $item_value) {
      $this->results->rows[$row_key][str_replace('ga:', '', $this->results->columnHeaders[$item_key]->name)] = $item_value;
    }
  }
  unset($this->results->rawRows);

  // Named keys for report totals.
  $this->results->rawTotals = $this->results->totalsForAllResults;
  $this->results->totalsForAllResults = [];
  foreach ($this->results->rawTotals as $row_key => $row_value) {
    $this->results->totalsForAllResults[str_replace('ga:', '', $row_key)] = $row_value;
  }
  unset($this->results->rawTotals);
}