Commit a2fc9850 authored by jhodgdon's avatar jhodgdon
Browse files

Issue #2490936 by cbanman, joshi.rohit100, ashutoshsngh, andypost, Cottser:...

Issue #2490936 by cbanman, joshi.rohit100, ashutoshsngh, andypost, Cottser: hook_library_info_alter() docs and function signature are slightly out of date
parent abb22d7d
...@@ -213,7 +213,7 @@ public function buildByExtension($extension) { ...@@ -213,7 +213,7 @@ public function buildByExtension($extension) {
} }
/** /**
* Parses a given library file and allows module to alter it. * Parses a given library file and allows modules and themes to alter it.
* *
* This method sets the parsed information onto the library property. * This method sets the parsed information onto the library property.
* *
......
...@@ -847,22 +847,26 @@ function hook_js_settings_alter(array &$settings, \Drupal\Core\Asset\AttachedAss ...@@ -847,22 +847,26 @@ function hook_js_settings_alter(array &$settings, \Drupal\Core\Asset\AttachedAss
} }
/** /**
* Alters the JavaScript/CSS library registry. * Alter libraries provided by an extension.
* *
* Allows certain, contributed modules to update libraries to newer versions * Allows modules and themes to change libraries' definitions; mostly used to
* while ensuring backwards compatibility. In general, such manipulations should * update a library to a newer version, while ensuring backward compatibility.
* only be done by designated modules, since most modules that integrate with a * In general, such manipulations should only be done to extend the library's
* certain library also depend on the API of a certain library version. * functionality in a backward-compatible way, to avoid breaking other modules
* * and themes that may be using the library.
* @param $libraries *
* The JavaScript/CSS libraries provided by $module. Keyed by internal library * @param array $libraries
* name and passed by reference. * An associative array of libraries registered by $extension. Keyed by
* @param $module * internal library name and passed by reference.
* The name of the module that registered the libraries. * @param string $extension
* Can either be 'core' or the machine name of the extension that registered
* the libraries.
*
* @see \Drupal\Core\Asset\LibraryDiscoveryParser::parseLibraryInfo()
*/ */
function hook_library_info_alter(&$libraries, $module) { function hook_library_info_alter(&$libraries, $extension) {
// Update Farbtastic to version 2.0. // Update Farbtastic to version 2.0.
if ($module == 'core' && isset($libraries['jquery.farbtastic'])) { if ($extension == 'core' && isset($libraries['jquery.farbtastic'])) {
// Verify existing version is older than the one we are updating to. // Verify existing version is older than the one we are updating to.
if (version_compare($libraries['jquery.farbtastic']['version'], '2.0', '<')) { if (version_compare($libraries['jquery.farbtastic']['version'], '2.0', '<')) {
// Update the existing Farbtastic to version 2.0. // Update the existing Farbtastic to version 2.0.
......
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