function BubblingTest::bubblingPreRender

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php \Drupal\Tests\Core\Render\BubblingTest::bubblingPreRender()
  2. 8.9.x core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php \Drupal\Tests\Core\Render\BubblingTest::bubblingPreRender()
  3. 10 core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php \Drupal\Tests\Core\Render\BubblingTest::bubblingPreRender()

#pre_render callback for testBubblingWithPrerender().

File

core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php, line 556

Class

BubblingTest

Namespace

Drupal\Tests\Core\Render

Code

public static function bubblingPreRender($elements) {
    $elements += [
        'child_cache_context' => [
            '#cache' => [
                'contexts' => [
                    'child.cache_context',
                ],
            ],
            '#markup' => 'Cache context!',
        ],
        'child_cache_tag' => [
            '#cache' => [
                'tags' => [
                    'child:cache_tag',
                ],
            ],
            '#markup' => 'Cache tag!',
        ],
        'child_asset' => [
            '#attached' => [
                'drupalSettings' => [
                    'foo' => 'bar',
                ],
            ],
            '#markup' => 'Asset!',
        ],
        'child_placeholder' => [
            '#create_placeholder' => TRUE,
            '#lazy_builder' => [
                __CLASS__ . '::bubblingPlaceholder',
                [
                    'bar',
                    'stool',
                ],
            ],
        ],
        'child_nested_pre_render_uncached' => [
            '#cache' => [
                'keys' => [
                    'uncached_nested',
                ],
            ],
            '#pre_render' => [
                __CLASS__ . '::bubblingNestedPreRenderUncached',
            ],
        ],
        'child_nested_pre_render_cached' => [
            '#cache' => [
                'keys' => [
                    'cached_nested',
                ],
            ],
            '#pre_render' => [
                __CLASS__ . '::bubblingNestedPreRenderCached',
            ],
        ],
    ];
    return $elements;
}

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