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
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.