You are here

function uma_CFV 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_CFV()

Get our form values.

File

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

Code

function uma_CFV() {

  // Get the form config.
  $config = \Drupal::config('user_menu_avatar.settings');

  // Get link text form value by langcode.
  $menuLinkText = $config
    ->get('link_text') ?: NULL;

  // Show menu avatar.
  $showAvatar = $config
    ->get('show_menu_avatar') ?: 'no';

  // Set the $name value.
  $showName = $config
    ->get('show_user_name') ?: 'no';

  // Get avatar shape form value.
  $avatarShape = $config
    ->get('avatar_shape') ?: 'circle';

  // Get avatar size form value.
  $avatarSize = $config
    ->get('avatar_size') ?: 50;

  // Get the avatar image field name form value.
  $avatarImageField = $config
    ->get('avatar_image_field') ?: 'user_picture';

  // Get the custom name field form value.
  $customNameField = $config
    ->get('avatar_custom_name_field') ?: '';

  // Show anonymous avatar.
  $showAnonymousAvatar = $config
    ->get('show_anonymous_avatar') ?: 'no';

  // Get the anonymous avatar.
  $anonymousUserAvatar = $config
    ->get('anonymous_user_avatar') ?: '';

  // Show anonymous user text.
  $showAnonymousName = $config
    ->get('show_anonymous_name') ?: 'no';

  // Get the anonymous user text.
  $customAnonymousText = $config
    ->get('custom_anonymous_text') ?: '';
  return [
    'menuLinkText' => $menuLinkText,
    'showAvatar' => $showAvatar,
    'showName' => $showName,
    'avatarShape' => $avatarShape,
    'avatarSize' => $avatarSize,
    'avatarImageField' => $avatarImageField,
    'customNameField' => $customNameField,
    'showAnonymousAvatar' => $showAnonymousAvatar,
    'anonymousUserAvatar' => $anonymousUserAvatar,
    'showAnonymousName' => $showAnonymousName,
    'customAnonymousText' => $customAnonymousText,
  ];
}