You are here

public function UltimenuTool::getRegionKey in Ultimenu 8.2

Gets the region key.

Parameters

object $link: The menu item link object.

int $max_length: The amount of characters to truncate.

Return value

string The region key name based on shortened UUID, or menu item title.

Overrides UltimenuToolInterface::getRegionKey

File

src/UltimenuTool.php, line 147

Class

UltimenuTool
Provides Ultimenu utility methods.

Namespace

Drupal\ultimenu

Code

public function getRegionKey($link, $max_length = self::MAX_LENGTH) {
  $menu_name = $link
    ->getMenuName();
  $key = $link
    ->getPluginId();
  $title = $this
    ->getTitle($link);
  $goodies = $this
    ->getSetting('goodies');
  $is_mlid = isset($goodies['ultimenu-mlid']) && $goodies['ultimenu-mlid'];
  $is_hash = isset($goodies['ultimenu-mlid-hash']) && $goodies['ultimenu-mlid-hash'];
  $menu_name = $this
    ->truncateRegionKey($menu_name, $max_length);
  if ($is_hash) {
    $menu_item = $this
      ->getShortenedHash($key);
  }
  elseif ($is_mlid) {
    $menu_item = $this
      ->getShortenedUuid($key);
  }
  else {
    $menu_item = $this
      ->truncateRegionKey(trim($title), $max_length);
  }
  return 'ultimenu_' . $menu_name . '_' . $menu_item;
}