You are here

public function IconSelectExtension::iconSelectRender in Icon Select 8

Returns an icon for a symbol id.

Return value

array A render array of an icon.

File

src/Twig/Extension/IconSelectExtension.php, line 34

Class

IconSelectExtension
Twig extension for icon rendering.

Namespace

Drupal\icon_select\Twig\Extension

Code

public function iconSelectRender($symbol_id, $classes = []) {

  /** @var \Drupal\Core\Template\Attribute $attributes */
  $attributes = new Attribute();

  // Prepare classes.
  $attributes
    ->addClass('icon', 'icon--' . $symbol_id);
  $attributes
    ->addClass($classes);
  $build = [
    '#theme' => 'icon_select_svg_icon',
    '#attributes' => $attributes,
    '#symbol_id' => $symbol_id,
  ];
  return $build;
}