function IconFinder::extractGroupFromPath

Extracts the group from a file path based on the group position.

Parameters

string $path: The file path.

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

Return value

string|null The extracted group, or null if not found.

1 call to IconFinder::extractGroupFromPath()
IconFinder::processFoundFiles in core/lib/Drupal/Core/Theme/Icon/IconFinder.php
Process files and format icon information.

File

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

Class

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

Namespace

Drupal\Core\Theme\Icon

Code

private static function extractGroupFromPath(string $path, ?int $group_position) : ?string {
    $parts = explode('/', trim($path, '/'));
    return $parts[$group_position] ?? NULL;
}

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