You are here

public function CommonTestController::jsAndCssQuerystring in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/system/tests/modules/common_test/src/Controller/CommonTestController.php \Drupal\common_test\Controller\CommonTestController::jsAndCssQuerystring()

Adds a JavaScript file and a CSS file with a query string appended.

Return value

string An empty string.

1 string reference to 'CommonTestController::jsAndCssQuerystring'
common_test.routing.yml in core/modules/system/tests/modules/common_test/common_test.routing.yml
core/modules/system/tests/modules/common_test/common_test.routing.yml

File

core/modules/system/tests/modules/common_test/src/Controller/CommonTestController.php, line 64

Class

CommonTestController
Controller routines for common_test routes.

Namespace

Drupal\common_test\Controller

Code

public function jsAndCssQuerystring() {
  $module_extension_list = \Drupal::service('extension.list.module');
  assert($module_extension_list instanceof ExtensionList);
  $attached = [
    '#attached' => [
      'library' => [
        'node/drupal.node',
      ],
      'css' => [
        $module_extension_list
          ->getPath('node') . '/css/node.admin.css' => [],
        // A relative URI may have a query string.
        '/' . $module_extension_list
          ->getPath('node') . '/node-fake.css?arg1=value1&arg2=value2' => [],
      ],
    ],
  ];
  return \Drupal::service('renderer')
    ->renderRoot($attached);
}