You are here

function paragraphs_grid_page_attachments in Paragraphs grid 8

Implements hook_page_attachments().

Append grid library.

File

./paragraphs_grid.module, line 128
Contains paragraphs_grid.module.

Code

function paragraphs_grid_page_attachments(array &$page) {

  // Get module configuration.
  $module_config = \Drupal::config('paragraphs_grid.settings');
  if ($module_config
    ->get('use_lib_admin_pages') || !\Drupal::service('router.admin_context')
    ->isAdminRoute()) {

    // Get configured grid-type-definition.
    $grid_type = $module_config
      ->get('gridtype');
    $grid_config = $grid_type ? \Drupal::config($grid_type) : NULL;

    // Attach library from pg module.
    if ($module_config
      ->get('uselibrary') && ($lib = $grid_config
      ->get('library'))) {
      $page['#attached']['library'][] = $lib;
    }
  }
}