function LibraryDiscoveryParser::resolveThemeAssetPath

Same name and namespace in other branches
  1. 8.9.x core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php \Drupal\Core\Asset\LibraryDiscoveryParser::resolveThemeAssetPath()
  2. 10 core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php \Drupal\Core\Asset\LibraryDiscoveryParser::resolveThemeAssetPath()
  3. 11.x core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php \Drupal\Core\Asset\LibraryDiscoveryParser::resolveThemeAssetPath()

Ensures that a full path is returned for an overriding theme asset.

Parameters

string $theme_path: The theme or base theme.

string $overriding_asset: The overriding library asset.

Return value

string A fully resolved theme asset path relative to the Drupal directory.

1 call to LibraryDiscoveryParser::resolveThemeAssetPath()
LibraryDiscoveryParser::setOverrideValue in core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
Overrides the specified library asset.

File

core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php, line 529

Class

LibraryDiscoveryParser
Parses library files to get extension data.

Namespace

Drupal\Core\Asset

Code

protected function resolveThemeAssetPath($theme_path, $overriding_asset) {
    if ($overriding_asset[0] !== '/' && !$this->isValidUri($overriding_asset)) {
        // The destination is not an absolute path and it's not a URI (e.g.
        // public://generated_js/example.js or http://example.com/js/my_js.js), so
        // it's relative to the theme.
        return '/' . $theme_path . '/' . $overriding_asset;
    }
    return $overriding_asset;
}

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