Commit 2ab81dbf authored by webchick's avatar webchick

Issue #2392717 by a_thakur, tadityar: Remove hook_library_alter() from theme.api.php

parent 5367cedb
......@@ -32,8 +32,8 @@ class LibraryDiscovery implements LibraryDiscoveryInterface {
/**
* The final library definitions, statically cached.
*
* hook_library_alter() allows modules and themes to dynamically alter a
* library definition (once per request).
* hook_library_info_alter() and hook_js_settings_alter() allows modules
* and themes to dynamically alter a library definition (once per request).
*
* @var array
*/
......
......@@ -787,39 +787,6 @@ function hook_library_info_alter(&$libraries, $module) {
}
}
/**
* Alters a JavaScript/CSS library before it is attached.
*
* Allows modules and themes to dynamically attach further assets to a library
* when it is added to the page; e.g., to add JavaScript settings.
*
* This hook is only invoked once per library and page.
*
* @param array $library
* The JavaScript/CSS library that is being added.
* @param string $name
* The name of the library.
*
* @see _drupal_add_library()
*
* @deprecated in Drupal 8.0.x, will be removed before Drupal 8.0.0
* Use hook_library_info_alter() and hook_js_settings_alter().
*/
function hook_library_alter(array &$library, $name) {
if ($name == 'core/jquery.ui.datepicker') {
// Note: If the added assets do not depend on additional request-specific
// data supplied here, consider to statically register it directly via
// hook_library_info_alter() already.
$library['dependencies'][] = 'locale/drupal.locale.datepicker';
$language_interface = \Drupal::languageManager()->getCurrentLanguage();
$library['drupalSettings']['jquery']['ui']['datepicker'] = array(
'isRTL' => $language_interface->getDirection() == LanguageInterface::DIRECTION_RTL,
'firstDay' => \Drupal::config('system.date')->get('first_day'),
);
}
}
/**
* Alter CSS files before they are output on the page.
*
......
......@@ -87,10 +87,11 @@ public function testGetLibrariesByExtension() {
);
$this->libraryDiscovery->getLibrariesbyExtension('test');
// Verify that subsequent calls don't trigger hook_library_alter()
// invocations, nor do they talk to the collector again. This ensures that
// the alterations made by hook_library_alter() implementations are
// statically cached, as desired.
// Verify that subsequent calls don't trigger hook_library_info_alter()
// and hook_js_settings_alter() invocations, nor do they talk to the
// collector again. This ensures that the alterations made by
// hook_library_info_alter() and hook_js_settings_alter() implementations
// are statically cached, as desired.
$this->libraryDiscovery->getLibraryByName('test', 'test_1');
$this->libraryDiscovery->getLibrariesbyExtension('test');
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment