Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hook_library support #161

Open
mglaman opened this issue Mar 21, 2024 · 0 comments
Open

hook_library support #161

mglaman opened this issue Mar 21, 2024 · 0 comments

Comments

@mglaman
Copy link
Collaborator

mglaman commented Mar 21, 2024

Invoke hook_library and create library definitions

Seems like it's best to decorate and implement \Drupal\Core\Asset\LibraryDiscoveryParser::buildByExtension

Example

function overlay_library() {
  $module_path = drupal_get_path('module', 'overlay');

  // Overlay parent.
  $libraries['parent'] = array(
    'title' => 'Overlay: Parent',
    'website' => 'http://drupal.org/documentation/modules/overlay',
    'version' => '1.0',
    'js' => array(
      $module_path . '/overlay-parent.js' => array(),
    ),
    'css' => array(
      $module_path . '/overlay-parent.css' => array(),
    ),
    'dependencies' => array(
      array('system', 'ui'),
      array('system', 'jquery.bbq'),
    ),
  );
  // Overlay child.
  $libraries['child'] = array(
    'title' => 'Overlay: Child',
    'website' => 'http://drupal.org/documentation/modules/overlay',
    'version' => '1.0',
    'js' => array(
      $module_path . '/overlay-child.js' => array(),
    ),
    'css' => array(
      $module_path . '/overlay-child.css' => array(),
    ),
  );

  return $libraries;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant