function _datalayer_get_field_values in dataLayer 8
Get values for exposed fields.
Parameters
object $entity: Entity being processed.
Return value
array Array keyed by field names.
2 calls to _datalayer_get_field_values()
- datalayer_get_user_data in ./
datalayer.module - Return all user data based on configured URL patterns.
- _datalayer_get_entity_data in ./
datalayer.module - Collect entity data for output and altering.
File
- ./
datalayer.module, line 479 - Client-side data space.
Code
function _datalayer_get_field_values($entity) {
$fields = [];
foreach ($entity
->getFieldDefinitions() as $field_name => $field_info) {
if (method_exists($field_info, 'getThirdPartySetting') && $field_info
->getThirdPartySetting('datalayer', 'expose', 0)) {
$field_type = $field_info
->getType();
if ($field_type != 'metatag') {
$fields[$field_info
->getThirdPartySetting('datalayer', 'label')] = [];
foreach ($entity->{$field_name} as $field_item) {
$fields[$field_info
->getThirdPartySetting('datalayer', 'label')] = _datalayer_field_get_value($field_item, $field_type);
}
}
else {
foreach ($entity->{$field_name} as $field_item) {
$subitems = _datalayer_field_get_value($field_item, $field_type);
if (!is_null($subitems)) {
foreach ($subitems as $key => $value) {
$fields[$key] = $value;
}
}
}
}
}
}
return $fields;
}