function JqueryUiTestAssetsController::build

Same name in other branches
  1. 9 core/modules/system/tests/modules/jqueryui_library_assets_test/src/Controller/JqueryUiTestAssetsController.php \Drupal\jqueryui_library_assets_test\Controller\JqueryUiTestAssetsController::build()
  2. 10 core/modules/system/tests/modules/jqueryui_library_assets_test/src/Controller/JqueryUiTestAssetsController.php \Drupal\jqueryui_library_assets_test\Controller\JqueryUiTestAssetsController::build()

Provides a page that loads a library.

Parameters

string $library: A pipe delimited list of library names.

Return value

array The render array.

1 string reference to 'JqueryUiTestAssetsController::build'
jqueryui_library_assets_test.routing.yml in core/modules/system/tests/modules/jqueryui_library_assets_test/jqueryui_library_assets_test.routing.yml
core/modules/system/tests/modules/jqueryui_library_assets_test/jqueryui_library_assets_test.routing.yml

File

core/modules/system/tests/modules/jqueryui_library_assets_test/src/Controller/JqueryUiTestAssetsController.php, line 23

Class

JqueryUiTestAssetsController
Controller for testing jQuery UI asset loading order.

Namespace

Drupal\jqueryui_library_assets_test\Controller

Code

public function build($library) {
    // If there are pipes in $library, they are separating multiple library
    // names.
    if (str_contains($library, '|')) {
        $library = explode('|', $library);
        $library = array_map(function ($item) {
            return "core/{$item}";
        }, $library);
    }
    else {
        $library = "core/{$library}";
    }
    return [
        '#markup' => 'I am a page for testing jQuery UI asset loading order.',
        '#attached' => [
            'library' => $library,
        ],
    ];
}

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