function CommonTestController::attachments

Same name in other branches
  1. 10 core/modules/system/tests/modules/common_test/src/Controller/CommonTestController.php \Drupal\common_test\Controller\CommonTestController::attachments()
  2. 11.x core/modules/system/tests/modules/common_test/src/Controller/CommonTestController.php \Drupal\common_test\Controller\CommonTestController::attachments()

Returns a response with early rendering in common_test_page_attachments.

Return value

\Symfony\Component\HttpFoundation\Response A new Response object.

1 string reference to 'CommonTestController::attachments'
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 101

Class

CommonTestController
Controller routines for common_test routes.

Namespace

Drupal\common_test\Controller

Code

public function attachments() {
    \Drupal::state()->set('common_test.hook_page_attachments.early_rendering', TRUE);
    $build = [
        '#title' => 'A title',
        'content' => [
            '#markup' => 'Some content',
        ],
    ];
    return \Drupal::service('main_content_renderer.html')->renderResponse($build, \Drupal::requestStack()->getCurrentRequest(), \Drupal::routeMatch());
}

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