You are here

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

Same name and namespace in other branches
  1. 8.5 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 236
Display user picture and/or user name in menu.

Code

function uma_apply_markup(&$variables, &$menu_link) {

  // Get clean link title to compare against.
  $title = rtrim(strip_tags($menu_link['title']));

  // Compare $title value.
  if ($title === uma_CFV()['configLinkText']) {

    // Replaces the link title with our markup.
    if (uma_ImageURL() != '' || uma_UserName() != '') {

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

      // Change the item title.
      $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);
  }
}