You are here

public static function PlaceholdersTest::callback in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Render/RendererTestBase.php \Drupal\Tests\Core\Render\PlaceholdersTest::callback()
  2. 9 core/tests/Drupal/Tests/Core/Render/RendererTestBase.php \Drupal\Tests\Core\Render\PlaceholdersTest::callback()

#lazy_builder callback; attaches setting, generates markup.

Parameters

string $animal: An animal.

bool $use_animal_as_array_key: TRUE if the $animal parameter should be used as an array key, FALSE if it should be used as a plain string.

Return value

array A renderable array.

2 calls to PlaceholdersTest::callback()
PlaceholdersTest::callbackPerUser in core/tests/Drupal/Tests/Core/Render/RendererTestBase.php
#lazy_builder callback; attaches setting, generates markup, user-specific.
PlaceholdersTest::callbackTagCurrentTemperature in core/tests/Drupal/Tests/Core/Render/RendererTestBase.php
#lazy_builder callback; attaches setting, generates markup, cache tag.

File

core/tests/Drupal/Tests/Core/Render/RendererTestBase.php, line 285
Contains \Drupal\Tests\Core\Render\RendererTestBase.

Class

PlaceholdersTest

Namespace

Drupal\Tests\Core\Render

Code

public static function callback($animal, $use_animal_as_array_key = FALSE) {
  $value = $animal;
  if ($use_animal_as_array_key) {
    $value = [
      $animal => TRUE,
    ];
  }
  return [
    '#markup' => '<p>This is a rendered placeholder!</p>',
    '#attached' => [
      'drupalSettings' => [
        'dynamic_animal' => $value,
      ],
    ],
  ];
}