function ComponentPluginManager::findAsset

Same name in this branch
  1. 11.x core/modules/sdc/src/ComponentPluginManager.php \Drupal\sdc\ComponentPluginManager::findAsset()
Same name and namespace in other branches
  1. 10 core/modules/sdc/src/ComponentPluginManager.php \Drupal\sdc\ComponentPluginManager::findAsset()

Finds assets related to the provided metadata file.

Parameters

string $component_directory: The component directory for the plugin.

string $machine_name: The component's machine name.

string $file_extension: The file extension to detect.

bool $make_relative: TRUE to make the filename relative to the core folder.

Return value

string|null Filenames, maybe relative to the core folder.

2 calls to ComponentPluginManager::findAsset()
ComponentPluginManager::alterDefinition in core/lib/Drupal/Core/Theme/ComponentPluginManager.php
Alters the plugin definition with computed properties.
ComponentPluginManager::libraryFromDefinition in core/lib/Drupal/Core/Theme/ComponentPluginManager.php
Creates the library declaration array from a component definition.

File

core/lib/Drupal/Core/Theme/ComponentPluginManager.php, line 442

Class

ComponentPluginManager
Defines a plugin manager to deal with components.

Namespace

Drupal\Core\Theme

Code

private function findAsset(string $component_directory, string $machine_name, string $file_extension, bool $make_relative = FALSE) : ?string {
    $absolute_path = sprintf('%s%s%s.%s', $component_directory, DIRECTORY_SEPARATOR, $machine_name, $file_extension);
    if (!file_exists($absolute_path)) {
        return NULL;
    }
    return $make_relative ? $this->makePathRelativeToLibraryRoot($absolute_path) : $absolute_path;
}

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