function common_test_js_alter

Same name and namespace in other branches
  1. 9 core/modules/system/tests/modules/common_test/common_test.module \common_test_js_alter()
  2. 10 core/modules/system/tests/modules/common_test/common_test.module \common_test_js_alter()

Implements hook_js_alter().

See also

\Drupal\KernelTests\Core\Asset\AttachedAssetsTest::testAlter()

File

core/modules/system/tests/modules/common_test/common_test.module, line 252

Code

function common_test_js_alter(&$javascript, AttachedAssetsInterface $assets, LanguageInterface $language) {
    // Attach alter.js above tableselect.js.
    $alter_js = \Drupal::service('extension.list.module')->getPath('common_test') . '/alter.js';
    if (array_key_exists($alter_js, $javascript) && array_key_exists('core/misc/tableselect.js', $javascript)) {
        $javascript[$alter_js]['weight'] = $javascript['core/misc/tableselect.js']['weight'] - 1;
    }
}

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