function ga_push_push_data_mapper in GA Push 8
Same name and namespace in other branches
- 7 ga_push.module \ga_push_push_data_mapper()
Helper function to translate data keys.
Parameters
array $key_map: Array with keys to translate.
array $data: Data push array.
bool $initialize_empty: Initialize empty values.
Return value
array Mapped data.
1 call to ga_push_push_data_mapper()
- ga_push_add_legacy_params in ./
ga_push.module - Maps old method keys to the new ones.
File
- ./
ga_push.module, line 871 - Drupal Module: GA Push.
Code
function ga_push_push_data_mapper(array $key_map, array $data, $initialize_empty = FALSE) {
$mapped_data = [];
foreach ($data as $key => $value) {
$mkey = isset($key_map[$key]) ? $key_map[$key] : $key;
$mapped_data[$mkey] = $value;
}
if ($initialize_empty) {
$mapped_data += array_fill_keys($key_map, '');
}
return $mapped_data;
}