You are here

public function MiconIcon::getChildren in Micon 8

Same name and namespace in other branches
  1. 2.x src/MiconIcon.php \Drupal\micon\MiconIcon::getChildren()

Get the content entered within the icon tags.

Return value

mixed[] A render array.

Overrides MiconIconInterface::getChildren

File

src/MiconIcon.php, line 110

Class

MiconIcon
Defines the Micon icon.

Namespace

Drupal\micon

Code

public function getChildren() {
  $build = [];
  if ($this->type == 'font') {

    // Font glyphs cannot have more than one color by default. Using CSS,
    // IcoMoon layers multiple glyphs on top of each other to implement
    // multicolor glyphs. As a result, these glyphs take more than one
    // character code and cannot have ligatures. To avoid multicolor glyphs,
    // reimport your SVG after changing all its colors to the same color.
    if (!empty($this->data['properties']['codes']) && count($this->data['properties']['codes'])) {
      for ($i = 1; $i <= count($this->data['properties']['codes']); $i++) {
        $build[]['#markup'] = '<span class="path' . $i . '"></span>';
      }
    }
  }
  if ($this->type == 'image') {
    $build['#markup'] = Markup::create('<use xlink:href="' . $this->data['directory'] . '/symbol-defs.svg#' . $this
      ->getSelector() . '"></use>');
    $build['#allowed_tags'] = [
      'use',
      'xlink',
    ];
  }
  return $build;
}