You are here

public function RenderAttachedTestController::header in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/system/tests/modules/render_attached_test/src/Controller/RenderAttachedTestController.php \Drupal\render_attached_test\Controller\RenderAttachedTestController::header()

Test attached HTML head rendering.

Return value

array A render array using the 'http_head' directive.

1 string reference to 'RenderAttachedTestController::header'
render_attached_test.routing.yml in core/modules/system/tests/modules/render_attached_test/render_attached_test.routing.yml
core/modules/system/tests/modules/render_attached_test/render_attached_test.routing.yml

File

core/modules/system/tests/modules/render_attached_test/src/Controller/RenderAttachedTestController.php, line 28

Class

RenderAttachedTestController
Controller for various permutations of #attached in the render array.

Namespace

Drupal\render_attached_test\Controller

Code

public function header() {
  $render = [];
  $render['#attached']['http_header'][] = [
    'X-Test-Teapot-Replace',
    'This value gets replaced',
  ];
  $render['#attached']['http_header'][] = [
    'X-Test-Teapot-Replace',
    'Teapot replaced',
    TRUE,
  ];
  $render['#attached']['http_header'][] = [
    'X-Test-Teapot-No-Replace',
    'This value is not replaced',
  ];
  $render['#attached']['http_header'][] = [
    'X-Test-Teapot-No-Replace',
    'This one is added',
    FALSE,
  ];
  $render['#attached']['http_header'][] = [
    'X-Test-Teapot',
    'Teapot Mode Active',
  ];
  return $render;
}