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.
1 | php[ 'js' ] |
or
1 | 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\Asset
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | 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 ); } } } } |
Please login to continue.