You are here

protected function StringMiconFormatter::viewIcon in Micon 8

Same name and namespace in other branches
  1. 2.x src/Plugin/Field/FieldFormatter/StringMiconFormatter.php \Drupal\micon\Plugin\Field\FieldFormatter\StringMiconFormatter::viewIcon()

Generate the output appropriate for one field item.

Parameters

\Drupal\Core\Field\FieldItemInterface $item: One field item.

Return value

\Drupal\micon\MiconIcon|null The Micon icon matching the icon_id.

1 call to StringMiconFormatter::viewIcon()
StringMiconFormatter::viewElements in src/Plugin/Field/FieldFormatter/StringMiconFormatter.php
Builds a renderable array for a field value.

File

src/Plugin/Field/FieldFormatter/StringMiconFormatter.php, line 47

Class

StringMiconFormatter
Plugin implementation of the 'string_micon' formatter.

Namespace

Drupal\micon\Plugin\Field\FieldFormatter

Code

protected function viewIcon(FieldItemInterface $item) {
  $icon_id = nl2br(Html::escape($item->value));
  return \Drupal::service('micon.icon.manager')
    ->getIconMatch($icon_id);
}