You are here

function micon_paragraphs_micon_icons_alter in Micon 8

Same name and namespace in other branches
  1. 2.x micon_paragraphs/micon_paragraphs.module \micon_paragraphs_micon_icons_alter()

Implements hook_micon_icons_alter().

File

micon_paragraphs/micon_paragraphs.module, line 60
Contains micon_paragraphs.module.

Code

function micon_paragraphs_micon_icons_alter(&$icons) {
  $defaults = [
    'text' => '',
    'regex' => '',
    'weight' => 0,
    'provider' => 'micon_paragraphs',
  ];
  $types = \Drupal::entityTypeManager()
    ->getStorage('paragraphs_type')
    ->loadMultiple();
  foreach ($types as $type) {
    if ($icon = micon_paragraphs_icon($type)) {
      $id = 'paragraphs.' . $type
        ->id();
      $icons[$id] = [
        'text' => 'paragraphs.' . strtolower($type
          ->label()),
        'icon' => $icon,
        'id' => $id,
      ] + $defaults;
      $icons[$id . '_bundle'] = [
        'text' => 'paragraphs.' . $type
          ->id(),
        'icon' => $icon,
        'id' => $id,
      ] + $defaults;
    }
  }
}