protected LibraryDiscoveryCollector::getLibraryDefinitions($extension)
Returns the library definitions for a given extension.
This also implements libraries-overrides for entire libraries that have been specified by the LibraryDiscoveryParser.
Parameters
string $extension: The name of the extension for which library definitions will be returned.
Return value
array The library definitions for $extension with overrides applied.
Throws
\Drupal\Core\Asset\Exception\InvalidLibrariesOverrideSpecificationException
File
- core/lib/Drupal/Core/Asset/LibraryDiscoveryCollector.php, line 86
Class
- LibraryDiscoveryCollector
- A CacheCollector implementation for building library extension info.
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 23 24 25 26 27 28 29 30 | protected function getLibraryDefinitions( $extension ) { $libraries = $this ->discoveryParser->buildByExtension( $extension ); foreach ( $libraries as $name => $definition ) { // Handle libraries that are marked for override or removal. // @see \Drupal\Core\Asset\LibraryDiscoveryParser::applyLibrariesOverride() if (isset( $definition [ 'override' ])) { if ( $definition [ 'override' ] === FALSE) { // Remove the library definition if FALSE is given. unset( $libraries [ $name ]); } else { // Otherwise replace with existing library definition if it exists. // Throw an exception if it doesn't. list( $replacement_extension , $replacement_name ) = explode ( '/' , $definition [ 'override' ]); $replacement_definition = $this ->get( $replacement_extension ); if (isset( $replacement_definition [ $replacement_name ])) { $libraries [ $name ] = $replacement_definition [ $replacement_name ]; } else { throw new InvalidLibrariesOverrideSpecificationException(sprintf( 'The specified library %s does not exist.' , $definition [ 'override' ])); } } } else { // If libraries are not overridden, then apply libraries-extend. $libraries [ $name ] = $this ->applyLibrariesExtend( $extension , $name , $definition ); } } return $libraries ; } |
Please login to continue.