many_assets_test.module

Same filename in other branches
  1. 9 core/modules/system/tests/modules/many_assets_test/many_assets_test.module
  2. 11.x core/modules/system/tests/modules/many_assets_test/many_assets_test.module

Helper module for asset load order test.

File

core/modules/system/tests/modules/many_assets_test/many_assets_test.module

View source
<?php


/**
 * @file
 * Helper module for asset load order test.
 */

/**
 * Implements hook_library_info_build().
 */
function many_assets_test_library_info_build() {
    $libraries = [];
    // Load the local javascript as an "external" asset varied by query string.
    $base_javascript = \Drupal::request()->getBasePath() . '/' . \Drupal::service('extension.list.module')->getPath('many_assets_test') . '/js/noop.js';
    $base_css = \Drupal::request()->getBasePath() . '/' . \Drupal::service('extension.list.module')->getPath('many_assets_test') . '/css/noop.css';
    // Build a library dependency containing 100 javascript assets.
    for ($i = 1; $i <= 150; $i++) {
        $libraries['many-dependencies']['js'][$base_javascript . '?dep' . $i] = [
            'type' => 'external',
        ];
        $libraries['many-dependencies']['css']['component'][$base_css . '?dep' . $i] = [
            'type' => 'external',
        ];
    }
    return $libraries;
}

Functions

Title Deprecated Summary
many_assets_test_library_info_build Implements hook_library_info_build().

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.