Skip to content

hook_library support #161

@mglaman

Description

@mglaman

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions