function PlaceholdersTest::callback

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Render/RendererTestBase.php \Drupal\Tests\Core\Render\PlaceholdersTest::callback()
  2. 8.9.x core/tests/Drupal/Tests/Core/Render/RendererTestBase.php \Drupal\Tests\Core\Render\PlaceholdersTest::callback()
  3. 11.x 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 304

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,
            ],
        ],
    ];
}

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