Extend a Module Library in a Module (like libraries-extend in Themes)

Motorcycly with fully packed trailer

In Drupal Themes its very easy to extend existing libraries using the themes .info (and .libraries) file. This ain’t possible in a Mobule .info file. So we need a hook to do this:

/**
 * Implements hook_library_info_alter()
 * - Extend some module libraries we support or require for MY_MODULE
 */
function MY_MODULE_library_info_alter(&$libraries, $extension) {
  if ($extension == 'views_bulk_operations' && isset($libraries['frontUi'])) {
    // Extend existing library views_bulk_operations/adminUi
    // Important! That a library is listed by this hook, doesn't mean the library is attached, it just means its registered.
    $libraries['frontUi']['dependencies'][] = 'MY_MODULE/MY_LIBRARY_NAME';
  }
}

    Schreibe einen Kommentar

    Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert


    Der Zeitraum für die reCAPTCHA-Überprüfung ist abgelaufen. Bitte laden Sie die Seite neu.