diff --git a/core/core.services.yml b/core/core.services.yml index 18d34b9..f5bc02e 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -1281,7 +1281,7 @@ services: class: Drupal\Core\Asset\AssetDumper library.discovery: class: Drupal\Core\Asset\LibraryDiscovery - arguments: ['@library.discovery.collector', '@module_handler'] + arguments: ['@library.discovery.collector', '@module_handler', '@theme.manager'] library.discovery.collector: class: Drupal\Core\Asset\LibraryDiscoveryCollector arguments: ['@cache.discovery', '@lock', '@library.discovery.parser'] @@ -1289,7 +1289,7 @@ services: - { name: needs_destruction } library.discovery.parser: class: Drupal\Core\Asset\LibraryDiscoveryParser - arguments: ['@app.root', '@module_handler'] + arguments: ['@app.root', '@module_handler', '@theme.manager'] library.dependency_resolver: class: Drupal\Core\Asset\LibraryDependencyResolver arguments: ['@library.discovery'] diff --git a/core/lib/Drupal/Core/Asset/LibraryDiscovery.php b/core/lib/Drupal/Core/Asset/LibraryDiscovery.php index c79674a..c15eab9 100644 --- a/core/lib/Drupal/Core/Asset/LibraryDiscovery.php +++ b/core/lib/Drupal/Core/Asset/LibraryDiscovery.php @@ -9,6 +9,7 @@ use Drupal\Core\Cache\CacheCollectorInterface; use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\Core\Theme\ThemeManagerInterface; /** * Discovers available asset libraries in Drupal. @@ -30,6 +31,13 @@ class LibraryDiscovery implements LibraryDiscoveryInterface { protected $moduleHandler; /** + * The theme manager. + * + * @var \Drupal\Core\Theme\ThemeManagerInterface + */ + protected $themeManager; + + /** * The final library definitions, statically cached. * * hook_library_info_alter() and hook_js_settings_alter() allows modules @@ -47,9 +55,10 @@ class LibraryDiscovery implements LibraryDiscoveryInterface { * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. */ - public function __construct(CacheCollectorInterface $library_discovery_collector, ModuleHandlerInterface $module_handler) { + public function __construct(CacheCollectorInterface $library_discovery_collector, ModuleHandlerInterface $module_handler, ThemeManagerInterface $theme_manager) { $this->collector = $library_discovery_collector; $this->moduleHandler = $module_handler; + $this->themeManager = $theme_manager; } /** @@ -64,6 +73,7 @@ public function getLibrariesByExtension($extension) { // specific data for this library; e.g., localization. $library_name = "$extension/$name"; $this->moduleHandler->alter('library', $definition, $library_name); + $this->themeManager->alter('library', $definition, $library_name); $this->libraryDefinitions[$extension][$name] = $definition; } } diff --git a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php index 26ba97a..7e9ba06 100644 --- a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php +++ b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php @@ -11,6 +11,7 @@ use Drupal\Core\Asset\Exception\InvalidLibraryFileException; use Drupal\Core\Asset\Exception\LibraryDefinitionMissingLicenseException; use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\Core\Theme\ThemeManagerInterface; use Drupal\Component\Serialization\Exception\InvalidDataTypeException; use Drupal\Component\Serialization\Yaml; use Drupal\Component\Utility\NestedArray; @@ -28,6 +29,13 @@ class LibraryDiscoveryParser { protected $moduleHandler; /** + * The theme manager. + * + * @var \Drupal\Core\Theme\ThemeManagerInterface + */ + protected $themeManager; + + /** * The app root. * * @var string @@ -42,9 +50,10 @@ class LibraryDiscoveryParser { * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler. */ - public function __construct($root, ModuleHandlerInterface $module_handler) { + public function __construct($root, ModuleHandlerInterface $module_handler, ThemeManagerInterface $theme_manager) { $this->root = $root; $this->moduleHandler = $module_handler; + $this->themeManager = $theme_manager; } /** @@ -241,6 +250,7 @@ protected function parseLibraryInfo($extension, $path) { // Allow modules to alter the module's registered libraries. $this->moduleHandler->alter('library_info', $libraries, $extension); + $this->themeManager->alter('library_info', $libraries, $extension); return $libraries; }