function IconFinder::processFoundFiles

Process files and format icon information.

Parameters

\Symfony\Component\Finder\Finder $finder: The Finder instance with found files.

string $source: The source.

string $path_info_filename: The filename from path_info().

int|null $group_position: The position of the group in the path, or null if not applicable.

Return value

array<string, array<string, string|null>> List of files with metadata.

1 call to IconFinder::processFoundFiles()
IconFinder::getFilesFromPath in core/lib/Drupal/Core/Theme/Icon/IconFinder.php
Get files from a local path.

File

core/lib/Drupal/Core/Theme/Icon/IconFinder.php, line 295

Class

IconFinder
Icon finder to discover files under specific paths or URLs.

Namespace

Drupal\Core\Theme\Icon

Code

private function processFoundFiles(Finder $finder, string $source, string $path_info_filename, ?int $group_position) : array {
    $result = [];
    $has_icon_pattern = \str_contains($path_info_filename, self::ICON_ID_PATTERN);
    foreach ($finder as $file) {
        $file_absolute_path = $file->getPathName();
        $icon_id = $file->getFilenameWithoutExtension();
        // If an {icon_id} pattern is used, extract it to be used.
        if ($has_icon_pattern) {
            $icon_id = self::extractIconIdFromFilename($icon_id, $path_info_filename);
        }
        // Icon ID is used as index to avoid duplicates.
        $result[$icon_id] = [
            'icon_id' => $icon_id,
            'source' => $this->fileUrlGenerator
                ->generateString(str_replace($this->appRoot, '', $file_absolute_path)),
            'absolute_path' => $file_absolute_path,
            'group' => self::extractGroupFromPath($file->getPath(), $group_position),
        ];
    }
    return $result;
}

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