function datalayer_get_data_from_page in dataLayer 8
Add data for output.
1 call to datalayer_get_data_from_page()
- datalayer_page_attachments in ./
datalayer.module - Implements hook_page_attachments().
File
- ./
datalayer.module, line 42 - Client-side data space.
Code
function datalayer_get_data_from_page() {
$datalayer_settings = \Drupal::config('datalayer.settings');
$user = \Drupal::currentUser();
// Add details about the page entity.
if ($datalayer_settings
->get('add_page_meta')) {
datalayer_add(datalayer_get_page_data());
}
// Expose user details.
if ($datalayer_settings
->get('expose_user_details')) {
datalayer_add(datalayer_get_user_data());
}
// Always output active uid.
$datalayer = datalayer_add([
'userUid' => $user
->id(),
]);
// Allow modules to alter data with hook_datalayer_alter().
\Drupal::moduleHandler()
->alter('datalayer', $datalayer);
return $datalayer;
}