function ComponentPluginManager::findAsset

Same name in this branch
  1. 11.x core/lib/Drupal/Core/Theme/ComponentPluginManager.php \Drupal\Core\Theme\ComponentPluginManager::findAsset()
Same name in other branches
  1. 10 core/modules/sdc/src/ComponentPluginManager.php \Drupal\sdc\ComponentPluginManager::findAsset()
  2. 10 core/lib/Drupal/Core/Theme/ComponentPluginManager.php \Drupal\Core\Theme\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 SDC module location.

Return value

string|null Filenames, maybe relative to the sdc module.

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

File

core/modules/sdc/src/ComponentPluginManager.php, line 449

Class

ComponentPluginManager
Defines a plugin manager to deal with sdc.

Namespace

Drupal\sdc

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.