summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJennifer Hodgdon2015-06-09 13:14:53 (GMT)
committerJennifer Hodgdon2015-06-09 13:14:53 (GMT)
commita2fc98503ad6094a4aad7ee5a3aebdb6046b8f87 (patch)
tree187751d34aafd67a189b50649760ce1c227c0ee5
parentabb22d7d9a1bebd74b46c8bf806e93f5974cffb9 (diff)
Issue #2490936 by cbanman, joshi.rohit100, ashutoshsngh, andypost, Cottser: hook_library_info_alter() docs and function signature are slightly out of date
-rw-r--r--core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php2
-rw-r--r--core/modules/system/theme.api.php32
2 files changed, 19 insertions, 15 deletions
diff --git a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
index 1c08bc9..e6a4376 100644
--- a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
+++ b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
@@ -213,7 +213,7 @@ class LibraryDiscoveryParser {
}
/**
- * 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.
*
diff --git a/core/modules/system/theme.api.php b/core/modules/system/theme.api.php
index 92a8342..fdba136 100644
--- a/core/modules/system/theme.api.php
+++ b/core/modules/system/theme.api.php
@@ -847,22 +847,26 @@ function hook_js_settings_alter(array &$settings, \Drupal\Core\Asset\AttachedAss
}
/**
- * Alters the JavaScript/CSS library registry.
- *
- * Allows certain, contributed modules to update libraries to newer versions
- * while ensuring backwards compatibility. In general, such manipulations should
- * only be done by designated modules, since most modules that integrate with a
- * certain library also depend on the API of a certain library version.
- *
- * @param $libraries
- * The JavaScript/CSS libraries provided by $module. Keyed by internal library
- * name and passed by reference.
- * @param $module
- * The name of the module that registered the libraries.
+ * Alter libraries provided by an extension.
+ *
+ * Allows modules and themes to change libraries' definitions; mostly used to
+ * update a library to a newer version, while ensuring backward compatibility.
+ * In general, such manipulations should only be done to extend the library's
+ * functionality in a backward-compatible way, to avoid breaking other modules
+ * and themes that may be using the library.
+ *
+ * @param array $libraries
+ * An associative array of libraries registered by $extension. Keyed by
+ * internal library name and passed by reference.
+ * @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.
- 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.
if (version_compare($libraries['jquery.farbtastic']['version'], '2.0', '<')) {
// Update the existing Farbtastic to version 2.0.