public function UltimenuTool::extractTitle in Ultimenu 8.2
Returns title with an icon class if available, e.g.: fa-mail|Contact us.
1 call to UltimenuTool::extractTitle()
- UltimenuTool::extractTitleHtml in src/
UltimenuTool.php - Returns titles as both HTML and plain text titles.
File
- src/
UltimenuTool.php, line 179
Class
- UltimenuTool
- Provides Ultimenu utility methods.
Namespace
Drupal\ultimenuCode
public function extractTitle($link) {
$title = strip_tags($link
->getTitle());
$is_icon = substr($title, 0, 5) === 'icon-';
$is_fontawesome = substr($title, 0, 3) === 'fa-';
if (strpos($title, '|') !== FALSE && ($is_icon || $is_fontawesome)) {
list($icon_class, $title) = array_pad(array_map('trim', explode("|", $title, 2)), 2, NULL);
return [
'icon' => $icon_class,
'title' => $title,
'fa' => $is_fontawesome,
];
}
// Ever had a client which adds an empty space to a menu title? I did.
return [
'title' => trim($title),
];
}