You are here

function gin_lb_preprocess_links__media_library_menu in Gin Layout Builder 1.0.x

Implements hook_preprocess_links__media_library_menu().

This targets the menu of available media types in the media library's modal dialog.

@todo Do this in the relevant template once https://www.drupal.org/project/drupal/issues/3088856 is resolved.

File

./gin_lb.module, line 480
Provides hooks for gin_lb module.

Code

function gin_lb_preprocess_links__media_library_menu(array &$variables) {
  if (gin_lb_is_valid_theme() === FALSE) {
    return;
  }
  foreach ($variables['links'] as &$link) {

    // Add a class to the Media Library menu items.
    $link['attributes']
      ->addClass('glb-media-library-menu__item');

    // This conditional exists because the media-library-menu__link class is
    // currently added by Classy, but Claro will eventually not use Classy as a
    // base theme.
    // @todo remove conditional, keep class addition in
    //   https://drupal.org/node/3110137
    // @see classy_preprocess_links__media_library_menu()
    if (!isset($link['link']['#options']['attributes']['class']) || !in_array('glb-media-library-menu__link', $link['link']['#options']['attributes']['class'])) {
      $link['link']['#options']['attributes']['class'][] = 'glb-media-library-menu__link';
    }
  }
}