You are here

function uma_apply_markup in User Menu Avatar (User Image in Menu) 8.5

Same name and namespace in other branches
  1. 8.4 user_menu_avatar.module \uma_apply_markup()

Apply markup per menu link.

Parameters

$variables: Variables.

$menu_link: Menu link item.

1 call to uma_apply_markup()
user_menu_avatar_preprocess_menu in ./user_menu_avatar.module
Implements hook_preprocess_hook().

File

./user_menu_avatar.module, line 274
Display user picture and/or user name in menu.

Code

function uma_apply_markup(&$variables, &$menu_link) {
  $title = $menu_link['title'] ? trim(strip_tags($menu_link['title'])) : NULL;

  // Compare menu link ID value.
  if ($title && $title === uma_CFV()['menuLinkText']) {

    // Get our markup.
    $markup = uma_Markup();

    // Replace title with our markup.
    $menu_link['title'] = $markup;

    // Attach our styles library.
    $variables['#attached']['library'][] = 'user_menu_avatar/styles';

    // Set cache context per user.
    $variables['#cache']['contexts'][] = 'user';
  }

  // Loop through second menu level.
  foreach ($menu_link['below'] as &$beKey) {
    uma_apply_markup($variables, $beKey);
  }
}