On this page
protected function LibraryDiscoveryParser::setOverrideValue
protected LibraryDiscoveryParser::setOverrideValue(array &$library, array $sub_key, array $overrides, $theme_path)
Overrides the specified library asset.
Parameters
array $library: The containing library definition.
array $sub_key: An array containing the sub-keys specifying the library asset, e.g.
php['js']
or
php['css', 'component']
array $overrides: Specifies the overrides, this is an array where the key is the asset to be overridden while the value is overriding asset.
File
- core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php, line 419
Class
- LibraryDiscoveryParser
- Parses library files to get extension data.
Namespace
Drupal\Core\AssetCode
protected function setOverrideValue(array &$library, array $sub_key, array $overrides, $theme_path) {
foreach ($overrides as $original => $replacement) {
// Get the attributes of the asset to be overridden. If the key does
// not exist, then throw an exception.
$key_exists = NULL;
$parents = array_merge($sub_key, [$original]);
// Save the attributes of the library asset to be overridden.
$attributes = NestedArray::getValue($library, $parents, $key_exists);
if ($key_exists) {
// Remove asset to be overridden.
NestedArray::unsetValue($library, $parents);
// No need to replace if FALSE is specified, since that is a removal.
if ($replacement) {
// Ensure the replacement path is relative to drupal root.
$replacement = $this->resolveThemeAssetPath($theme_path, $replacement);
$new_parents = array_merge($sub_key, [$replacement]);
// Replace with an override if specified.
NestedArray::setValue($library, $new_parents, $attributes);
}
}
}
}
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Asset!LibraryDiscoveryParser.php/function/LibraryDiscoveryParser::setOverrideValue/8.1.x