function SvgSpriteExtractor::discoverIcons

Overrides IconExtractorInterface::discoverIcons

File

core/lib/Drupal/Core/Theme/Plugin/IconExtractor/SvgSpriteExtractor.php, line 35

Class

SvgSpriteExtractor
Plugin implementation of the icon_extractor.

Namespace

Drupal\Core\Theme\Plugin\IconExtractor

Code

public function discoverIcons() : array {
    $files = $this->getFilesFromSources();
    if (empty($files)) {
        return [];
    }
    $icons = [];
    foreach ($files as $file) {
        $icon_ids = $this->extractIdsFromXml($file['absolute_path'] ?? '');
        foreach ($icon_ids as $icon_id) {
            $id = IconDefinition::createIconId($this->configuration['id'], (string) $icon_id);
            $icons[$id] = [
                'absolute_path' => $file['absolute_path'],
                'source' => $file['source'],
                'group' => $file['group'] ?? NULL,
            ];
        }
    }
    return $icons;
}

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