Skip to content
Snippets Groups Projects
Commit 3f3ebc75 authored by Jess's avatar Jess
Browse files

Issue #2472547 by lauriii, dawehner: Remove deprecated hook_library_alter()

parent f8514fe4
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -1280,7 +1280,7 @@ services: ...@@ -1280,7 +1280,7 @@ services:
class: Drupal\Core\Asset\AssetDumper class: Drupal\Core\Asset\AssetDumper
library.discovery: library.discovery:
class: Drupal\Core\Asset\LibraryDiscovery class: Drupal\Core\Asset\LibraryDiscovery
arguments: ['@library.discovery.collector', '@cache_tags.invalidator', '@module_handler', '@theme.manager'] arguments: ['@library.discovery.collector', '@cache_tags.invalidator']
library.discovery.collector: library.discovery.collector:
class: Drupal\Core\Asset\LibraryDiscoveryCollector class: Drupal\Core\Asset\LibraryDiscoveryCollector
arguments: ['@cache.discovery', '@lock', '@library.discovery.parser', '@theme.manager'] arguments: ['@cache.discovery', '@lock', '@library.discovery.parser', '@theme.manager']
......
...@@ -31,20 +31,6 @@ class LibraryDiscovery implements LibraryDiscoveryInterface { ...@@ -31,20 +31,6 @@ class LibraryDiscovery implements LibraryDiscoveryInterface {
*/ */
protected $cacheTagInvalidator; protected $cacheTagInvalidator;
/**
* The module handler.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $moduleHandler;
/**
* The theme manager.
*
* @var \Drupal\Core\Theme\ThemeManagerInterface
*/
protected $themeManager;
/** /**
* The final library definitions, statically cached. * The final library definitions, statically cached.
* *
...@@ -67,11 +53,9 @@ class LibraryDiscovery implements LibraryDiscoveryInterface { ...@@ -67,11 +53,9 @@ class LibraryDiscovery implements LibraryDiscoveryInterface {
* @param \Drupal\Core\Theme\ThemeManagerInterface $theme_manager * @param \Drupal\Core\Theme\ThemeManagerInterface $theme_manager
* The theme manager. * The theme manager.
*/ */
public function __construct(CacheCollectorInterface $library_discovery_collector, CacheTagsInvalidatorInterface $cache_tag_invalidator, ModuleHandlerInterface $module_handler, ThemeManagerInterface $theme_manager) { public function __construct(CacheCollectorInterface $library_discovery_collector, CacheTagsInvalidatorInterface $cache_tag_invalidator) {
$this->collector = $library_discovery_collector; $this->collector = $library_discovery_collector;
$this->cacheTagInvalidator = $cache_tag_invalidator; $this->cacheTagInvalidator = $cache_tag_invalidator;
$this->moduleHandler = $module_handler;
$this->themeManager = $theme_manager;
} }
/** /**
...@@ -85,8 +69,6 @@ public function getLibrariesByExtension($extension) { ...@@ -85,8 +69,6 @@ public function getLibrariesByExtension($extension) {
// Allow modules and themes to dynamically attach request and context // Allow modules and themes to dynamically attach request and context
// specific data for this library; e.g., localization. // specific data for this library; e.g., localization.
$library_name = "$extension/$name"; $library_name = "$extension/$name";
$this->moduleHandler->alter('library', $definition, $library_name);
$this->themeManager->alter('library', $definition, $library_name);
$this->libraryDefinitions[$extension][$name] = $definition; $this->libraryDefinitions[$extension][$name] = $definition;
} }
} }
......
...@@ -30,20 +30,6 @@ class LibraryDiscoveryTest extends UnitTestCase { ...@@ -30,20 +30,6 @@ class LibraryDiscoveryTest extends UnitTestCase {
*/ */
protected $libraryDiscoveryCollector; protected $libraryDiscoveryCollector;
/**
* The mocked module handler.
*
* @var \Drupal\Core\Extension\ModuleHandlerInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $moduleHandler;
/**
* The mocked theme manager.
*
* @var \Drupal\Core\Theme\ThemeManagerInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $themeManager;
/** /**
* The cache tags invalidator. * The cache tags invalidator.
* *
...@@ -81,9 +67,7 @@ protected function setUp() { ...@@ -81,9 +67,7 @@ protected function setUp() {
$this->libraryDiscoveryCollector = $this->getMockBuilder('Drupal\Core\Asset\LibraryDiscoveryCollector') $this->libraryDiscoveryCollector = $this->getMockBuilder('Drupal\Core\Asset\LibraryDiscoveryCollector')
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$this->moduleHandler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface'); $this->libraryDiscovery = new LibraryDiscovery($this->libraryDiscoveryCollector, $this->cacheTagsInvalidator);
$this->themeManager = $this->getMock('Drupal\Core\Theme\ThemeManagerInterface');
$this->libraryDiscovery = new LibraryDiscovery($this->libraryDiscoveryCollector, $this->cacheTagsInvalidator, $this->moduleHandler, $this->themeManager);
} }
/** /**
...@@ -94,20 +78,6 @@ public function testGetLibrariesByExtension() { ...@@ -94,20 +78,6 @@ public function testGetLibrariesByExtension() {
->method('get') ->method('get')
->with('test') ->with('test')
->willReturn($this->libraryData); ->willReturn($this->libraryData);
$this->moduleHandler->expects($this->exactly(2))
->method('alter')
->with(
'library',
$this->logicalOr($this->libraryData['test_1'], $this->libraryData['test_2']),
$this->logicalOr('test/test_1', 'test/test_2')
);
$this->themeManager->expects($this->exactly(2))
->method('alter')
->with(
'library',
$this->logicalOr($this->libraryData['test_1'], $this->libraryData['test_2']),
$this->logicalOr('test/test_1', 'test/test_2')
);
$this->libraryDiscovery->getLibrariesbyExtension('test'); $this->libraryDiscovery->getLibrariesbyExtension('test');
// Verify that subsequent calls don't trigger hook_library_info_alter() // Verify that subsequent calls don't trigger hook_library_info_alter()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment