function CommonTestThemeHooks::jsAlter

Implements hook_js_alter().

Attributes

#[Hook('js_alter')]

See also

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

File

core/modules/system/tests/modules/common_test/src/Hook/CommonTestThemeHooks.php, line 115

Class

CommonTestThemeHooks
Hook implementations for common_test.

Namespace

Drupal\common_test\Hook

Code

public function jsAlter(&$javascript, AttachedAssetsInterface $assets, LanguageInterface $language) : void {
  // 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.