Skip to content

Commit f13e0e1

Browse files
committed
Allow rendering fallback icons
1 parent 2624ca6 commit f13e0e1

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

Dashboard.module

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,13 +490,33 @@ class Dashboard extends Process implements Module
490490
/**
491491
* Render icon as markup.
492492
*
493-
* @param string $icon
493+
* @param string|array $icons Icon or icon array, in order of preference
494494
*
495495
* @return string Icon markup
496496
*/
497-
public function renderIcon($icon)
497+
public function renderIcon($icons)
498498
{
499-
return $icon ? wireIconMarkup($icon, 'fw') : '';
499+
$class = '';
500+
501+
if (empty($icons)) {
502+
$icons = [];
503+
} elseif (is_string($icons)) {
504+
$icons = [$icons];
505+
}
506+
if (is_array($icons)) {
507+
$classes = array_map(function ($icon) {
508+
if (strpos($icon, 'icon-') === 0) {
509+
$icon = str_replace('icon-', 'fa-', $icon);
510+
}
511+
if (strpos($icon, 'fa-') !== 0) {
512+
$icon = "fa-{$icon}";
513+
}
514+
return $icon;
515+
}, $icons);
516+
$class = implode(' ', $classes);
517+
}
518+
519+
return "<i class='fa fa-fw {$class}'></i>";
500520
}
501521

502522
/**

0 commit comments

Comments
 (0)