function _bootstrap_glyphicon
8.x-3.x deprecated.php | _bootstrap_glyphicon($name, $default = [], array $attributes = []) |
7.x-3.x common.inc | _bootstrap_glyphicon($name, $default = array(), array $attributes = array()) |
Returns a specific Bootstrap Glyphicon as a render array.
Note: This function was added in 7.x-3.17 to keep BC with the former _bootstrap_icon() implementation since it didn't return a render array. It is basically a backport of 8.x-3.x code so the added $attributes parameter can be more easily dealt with.
// Before.
$icon = _bootstrap_glyphicon($name, $default, $attributes);
// After.
use Drupal\bootstrap\Bootstrap;
use Drupal\bootstrap\Utility\Element;
$icon = Bootstrap::glyphicon($name, ['#markup' => $default]);
$icon_attributes = isset($icon['#attributes']) ? $icon['#attributes'] : [];
unset($icon['#attributes']);
$icon = Element::createStandalone($icon)->setAttributes($attributes)->setAttributes($icon_attributes)->getArray();
Parameters
string $name: The icon name, minus the "glyphicon-" prefix.
array|string $default: (Optional) The default render array to use if $name is not available.
array $attributes: (Optional) Additional attributes to merge onto the icon.
Return value
array The render containing the icon defined by $name, $default value if icon does not exist or returns NULL if no icon could be rendered.
Deprecated
Will be removed in a future release.
See Also
Source ./deprecated.php (line 387)
function _bootstrap_glyphicon($name, $default = [], array $attributes = []) {
Bootstrap::deprecated();
$icon = Bootstrap::glyphicon($name, ['#markup' => $default]);
$icon_attributes = isset($icon['#attributes']) ? $icon['#attributes'] : [];
unset($icon['#attributes']);
return Element::createStandalone($icon)->setAttributes($attributes)->setAttributes($icon_attributes)->getArray();
}