Commit 6fd99dba authored by Dries's avatar Dries

- Patch #1286868 by rickmanelius: rename hook_library() and...

- Patch #1286868 by rickmanelius: rename hook_library() and hook_library_alter() to standard pattern.
parent 80a6aef6
......@@ -4500,8 +4500,8 @@ function drupal_process_states(&$elements) {
* its dependencies could not be added.
*
* @see drupal_get_library()
* @see hook_library()
* @see hook_library_alter()
* @see hook_library_info()
* @see hook_library_info_alter()
*/
function drupal_add_library($module, $name, $every_page = NULL) {
$added = &drupal_static(__FUNCTION__, array());
......@@ -4551,8 +4551,8 @@ function drupal_add_library($module, $name, $every_page = NULL) {
* of libraries registered by $module is returned (which may be empty).
*
* @see drupal_add_library()
* @see hook_library()
* @see hook_library_alter()
* @see hook_library_info()
* @see hook_library_info_alter()
*
* @todo The purpose of drupal_get_*() is completely different to other page
* requisite API functions; find and use a different name.
......@@ -4562,12 +4562,12 @@ function drupal_get_library($module, $name = NULL) {
if (!isset($libraries[$module])) {
// Retrieve all libraries associated with the module.
$module_libraries = module_invoke($module, 'library');
$module_libraries = module_invoke($module, 'library_info');
if (empty($module_libraries)) {
$module_libraries = array();
}
// Allow modules to alter the module's registered libraries.
drupal_alter('library', $module_libraries, $module);
drupal_alter('library_info', $module_libraries, $module);
foreach ($module_libraries as $key => $data) {
if (is_array($data)) {
......
......@@ -36,9 +36,9 @@ function contextual_permission() {
}
/**
* Implements hook_library().
* Implements hook_library_info().
*/
function contextual_library() {
function contextual_library_info() {
$path = drupal_get_path('module', 'contextual');
$libraries['contextual-links'] = array(
'title' => 'Contextual links',
......
......@@ -935,11 +935,11 @@ function locale_css_alter(&$css) {
}
/**
* Implement hook_library_alter().
* Implement hook_library_info_alter().
*
* Provides the language support for the jQuery UI Date Picker.
*/
function locale_library_alter(&$libraries, $module) {
function locale_library_info_alter(&$libraries, $module) {
global $language;
if ($module == 'system' && isset($libraries['system']['ui.datepicker'])) {
$datepicker = drupal_get_path('module', 'locale') . '/locale.datepicker.js';
......
......@@ -194,9 +194,9 @@ function overlay_exit() {
}
/**
* Implements hook_library().
* Implements hook_library_info().
*/
function overlay_library() {
function overlay_library_info() {
$module_path = drupal_get_path('module', 'overlay');
// Overlay parent.
......
......@@ -1401,14 +1401,14 @@ class JavaScriptTestCase extends DrupalWebTestCase {
/**
* Adds a JavaScript library to the page and alters it.
*
* @see common_test_library_alter()
* @see common_test_library_info_alter()
*/
function testLibraryAlter() {
// Verify that common_test altered the title of Farbtastic.
$library = drupal_get_library('system', 'farbtastic');
$this->assertEqual($library['title'], 'Farbtastic: Altered Library', t('Registered libraries were altered.'));
// common_test_library_alter() also added a dependency on jQuery Form.
// common_test_library_info_alter() also added a dependency on jQuery Form.
drupal_add_library('system', 'farbtastic');
$scripts = drupal_get_js();
$this->assertTrue(strpos($scripts, 'misc/jquery.form.js'), t('Altered library dependencies are added to the page.'));
......@@ -1417,7 +1417,7 @@ class JavaScriptTestCase extends DrupalWebTestCase {
/**
* Tests that multiple modules can implement the same library.
*
* @see common_test_library()
* @see common_test_library_info()
*/
function testLibraryNameConflicts() {
$farbtastic = drupal_get_library('common_test', 'farbtastic');
......@@ -1455,10 +1455,10 @@ class JavaScriptTestCase extends DrupalWebTestCase {
// Retrieve all libraries registered by a module.
$libraries = drupal_get_library('common_test');
$this->assertTrue(isset($libraries['farbtastic']), t('Retrieved all module libraries.'));
// Retrieve all libraries for a module not implementing hook_library().
// Retrieve all libraries for a module not implementing hook_library_info().
// Note: This test installs Locale module.
$libraries = drupal_get_library('locale');
$this->assertEqual($libraries, array(), t('Retrieving libraries from a module not implementing hook_library() returns an emtpy array.'));
$this->assertEqual($libraries, array(), t('Retrieving libraries from a module not implementing hook_library_info() returns an emtpy array.'));
// Retrieve a specific library by module and name.
$farbtastic = drupal_get_library('common_test', 'farbtastic');
......
......@@ -184,9 +184,9 @@ function theme_common_test_foo($variables) {
}
/**
* Implements hook_library_alter().
* Implements hook_library_info_alter().
*/
function common_test_library_alter(&$libraries, $module) {
function common_test_library_info_alter(&$libraries, $module) {
if ($module == 'system' && isset($libraries['farbtastic'])) {
// Change the title of Farbtastic to "Farbtastic: Altered Library".
$libraries['farbtastic']['title'] = 'Farbtastic: Altered Library';
......@@ -196,11 +196,11 @@ function common_test_library_alter(&$libraries, $module) {
}
/**
* Implements hook_library().
* Implements hook_library_info().
*
* Adds Farbtastic in a different version.
*/
function common_test_library() {
function common_test_library_info() {
$libraries['farbtastic'] = array(
'title' => 'Custom Farbtastic Library',
'website' => 'http://code.google.com/p/farbtastic/',
......
......@@ -326,11 +326,11 @@ function hook_js_alter(&$javascript) {
* @return
* An array defining libraries associated with a module.
*
* @see system_library()
* @see system_library_info()
* @see drupal_add_library()
* @see drupal_get_library()
*/
function hook_library() {
function hook_library_info() {
// Library One.
$libraries['library-1'] = array(
'title' => 'Library One',
......@@ -384,9 +384,9 @@ function hook_library() {
* @param $module
* The name of the module that registered the libraries.
*
* @see hook_library()
* @see hook_library_info()
*/
function hook_library_alter(&$libraries, $module) {
function hook_library_info_alter(&$libraries, $module) {
// Update Farbtastic to version 2.0.
if ($module == 'system' && isset($libraries['farbtastic'])) {
// Verify existing version is older than the one we are updating to.
......
......@@ -1075,9 +1075,9 @@ function _system_batch_theme() {
}
/**
* Implements hook_library().
* Implements hook_library_info().
*/
function system_library() {
function system_library_info() {
// Drupal's Ajax framework.
$libraries['drupal.ajax'] = array(
'title' => 'Drupal AJAX',
......
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