public static function GoogleAnalyticsReports::saveFields in Google Analytics Reports 8.3
Batch processor.
Saves Google Analytics fields from Metadata API to database.
Parameters
array $field: Field definition.
array|\ArrayAccess $context: Context.
1 call to GoogleAnalyticsReports::saveFields()
- drush_google_analytics_reports_fields in ./
google_analytics_reports.drush.inc - Imports Google Analytics Fields.
File
- src/
GoogleAnalyticsReports.php, line 132
Class
- GoogleAnalyticsReports
- GoogleAnalyticsReports service class.
Namespace
Drupal\google_analytics_reportsCode
public static function saveFields(array $field, &$context) {
$attributes =& $field['attributes'];
$field['id'] = str_replace('ga:', '', $field['id']);
$attributes['type'] = strtolower($attributes['type']);
$attributes['dataType'] = strtolower($attributes['dataType']);
$attributes['status'] = strtolower($attributes['status']);
$attributes['description'] = isset($attributes['description']) ? $attributes['description'] : '';
$attributes['calculation'] = isset($attributes['calculation']) ? $attributes['calculation'] : NULL;
// Allow other modules to alter Google Analytics fields before saving
// in database.
\Drupal::moduleHandler()
->alter('google_analytics_reports_field_import', $field);
\Drupal::database()
->insert('google_analytics_reports_fields')
->fields([
'gaid' => $field['id'],
'type' => $attributes['type'],
'data_type' => $attributes['dataType'],
'column_group' => $attributes['group'],
'ui_name' => $attributes['uiName'],
'description' => $attributes['description'],
'calculation' => $attributes['calculation'],
])
->execute();
$context['results'][] = $field['id'];
}