function IconPackManager::getIcons

Get a list of all the icons within definitions.

Parameters

array $allowed_icon_pack: Limit the icons to some definition id.

Return value

array Gets a list of icons index by id with `source` and `group`.

Overrides IconPackManagerInterface::getIcons

File

core/lib/Drupal/Core/Theme/Icon/Plugin/IconPackManager.php, line 240

Class

IconPackManager
Defines an icon pack plugin manager to deal with icons.

Namespace

Drupal\Core\Theme\Icon\Plugin

Code

public function getIcons(array $allowed_icon_pack = []) : array {
  $definitions = $this->getDefinitions();
  if (NULL === $definitions) {
    return [];
  }
  $icons = [];
  foreach ($definitions as $definition) {
    if ($allowed_icon_pack && !in_array($definition['id'], $allowed_icon_pack, TRUE)) {
      continue;
    }
    $icons = array_merge($icons, $definition['icons'] ?? []);
  }
  return $icons;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.