You are here

public static function Bootstrap::glyphicon in Express 8

Returns a specific Bootstrap Glyphicon.

Parameters

string $name: The icon name, minus the "glyphicon-" prefix.

array $default: (Optional) The default render array to use if $name is not available.

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.

9 calls to Bootstrap::glyphicon()
Bootstrap::glyphiconFromString in themes/contrib/bootstrap/src/Bootstrap.php
Matches a Bootstrap Glyphicon based on a string value.
BootstrapCarousel::preprocessVariables in themes/contrib/bootstrap/src/Plugin/Preprocess/BootstrapCarousel.php
Preprocess the variables array.
FileLink::preprocessVariables in themes/contrib/bootstrap/src/Plugin/Preprocess/FileLink.php
Preprocess the variables array.
FileUploadHelp::preprocessVariables in themes/contrib/bootstrap/src/Plugin/Preprocess/FileUploadHelp.php
Preprocess the variables array.
NodePreviewFormSelect::alterFormElement in themes/contrib/bootstrap/src/Plugin/Form/NodePreviewFormSelect.php
The alter method to store the code.

... See full list

File

themes/contrib/bootstrap/src/Bootstrap.php, line 588
Contains \Drupal\bootstrap\Bootstrap.

Class

Bootstrap
The primary class for the Drupal Bootstrap base theme.

Namespace

Drupal\bootstrap

Code

public static function glyphicon($name, $default = []) {
  $icon = [];

  // Ensure the icon specified is a valid Bootstrap Glyphicon.
  // @todo Supply a specific version to _bootstrap_glyphicons() when Icon API
  // supports versioning.
  if (self::getTheme()
    ->hasGlyphicons() && in_array($name, self::glyphicons())) {

    // Attempt to use the Icon API module, if enabled and it generates output.
    if (\Drupal::moduleHandler()
      ->moduleExists('icon')) {
      $icon = [
        '#type' => 'icon',
        '#bundle' => 'bootstrap',
        '#icon' => 'glyphicon-' . $name,
      ];
    }
    else {
      $icon = [
        '#type' => 'html_tag',
        '#tag' => 'span',
        '#value' => '',
        '#attributes' => [
          'class' => [
            'icon',
            'glyphicon',
            'glyphicon-' . $name,
          ],
          'aria-hidden' => 'true',
        ],
      ];
    }
  }
  return $icon ?: $default;
}