You are here

public function RenderAttachedTestController::htmlHeaderLink in Drupal 10

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

Tests HTTP header rendering for link.

Return value

array A render array using the 'html_head_link' directive.

1 string reference to 'RenderAttachedTestController::htmlHeaderLink'
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 78

Class

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

Namespace

Drupal\render_attached_test\Controller

Code

public function htmlHeaderLink() {
  $render = [];
  $render['#attached']['html_head_link'][] = [
    [
      'href' => '/foo?bar=<baz>&baz=false',
      'rel' => 'alternate',
    ],
    TRUE,
  ];
  $render['#attached']['html_head_link'][] = [
    [
      'href' => '/not-added-to-http-headers',
      'rel' => 'alternate',
    ],
    FALSE,
  ];
  $render['#attached']['html_head_link'][] = [
    [
      'href' => '/foo/bar',
      'hreflang' => 'nl',
      'rel' => 'alternate',
    ],
    TRUE,
  ];
  $render['#attached']['html_head_link'][] = [
    [
      'href' => '/foo/bar',
      'hreflang' => 'de',
      'rel' => 'alternate',
    ],
    TRUE,
  ];
  return $render;
}