You are here

function tmgmt_smartling_page_attachments in TMGMT Translator Smartling 8.4

Same name and namespace in other branches
  1. 8.3 tmgmt_smartling.module \tmgmt_smartling_page_attachments()

Implements hook_page_attachments().

File

./tmgmt_smartling.module, line 912
Contains

Code

function tmgmt_smartling_page_attachments(array &$attachments) {
  $current_user = \Drupal::currentUser();
  if (!$current_user
    ->hasPermission("see smartling messages")) {
    return;
  }
  $firebaseConfigs = \Drupal::getContainer()
    ->get('tmgmt_smartling.firebase_config_manager')
    ->getAvailableConfigs();
  if ($firebaseConfigs) {
    $attachments['#attached']['drupalSettings']['tmgmt_smartling']['firebase']['configs'] = $firebaseConfigs;
    $attachments['#attached']['library'][] = 'tmgmt_smartling/firebase';
    $attachments['#attached']['library'][] = 'tmgmt_smartling/notifications';
  }
}