function mmenu_get_icon_class in Mobile sliding menu 8
Same name and namespace in other branches
- 7.3 mmenu.module \mmenu_get_icon_class()
- 7.2 mmenu.module \mmenu_get_icon_class()
Get the icon class for the given path or block title.
Parameters
string $type: The type of the icon. Possible values: path or block.
string $value: The info of the given path or block.
Return value
string An icon class name.
1 call to mmenu_get_icon_class()
- theme_mmenu_tree in ./
mmenu.module - Returns HTML for a wrapper for a mmenu tree.
File
- ./
mmenu.module, line 940 - Primarily Drupal hooks and global API functions to manipulate mmenus.
Code
function mmenu_get_icon_class($type = 'path', $value = '') {
$language = \Drupal::languageManager()
->getCurrentLanguage();
$icons = mmenu_icon_list();
$class = '';
switch ($type) {
case 'path':
$value = trim($value, '/');
// Remove language string.
$value = ltrim($value, $language
->getId());
if (empty($value)) {
$value = 'home';
}
$class = isset($icons['path'][$value]) ? $icons['path'][$value] : 'icon-list2';
break;
case 'block':
foreach ($icons['block'] as $block) {
if ($block['module'] == $value['module'] && $block['delta'] == $value['delta']) {
return $block['icon_class'];
}
}
$class = 'icon-list2';
break;
}
return $class;
}