class BubblingTest

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php \Drupal\Tests\Core\Render\BubblingTest
  2. 8.9.x core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php \Drupal\Tests\Core\Render\BubblingTest
  3. 11.x core/tests/Drupal/Tests/Core/Render/RendererBubblingTest.php \Drupal\Tests\Core\Render\BubblingTest

Hierarchy

Expanded class hierarchy of BubblingTest

File

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

Namespace

Drupal\Tests\Core\Render
View source
class BubblingTest implements TrustedCallbackInterface {
    
    /**
     * #pre_render callback for testBubblingWithPrerender().
     */
    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;
    }
    
    /**
     * #pre_render callback for testBubblingWithPrerender().
     */
    public static function bubblingNestedPreRenderUncached($elements) {
        \Drupal::state()->set('bubbling_nested_pre_render_uncached', TRUE);
        $elements['#markup'] = 'Nested!';
        return $elements;
    }
    
    /**
     * #pre_render callback for testBubblingWithPrerender().
     */
    public static function bubblingNestedPreRenderCached($elements) {
        \Drupal::state()->set('bubbling_nested_pre_render_cached', TRUE);
        return $elements;
    }
    
    /**
     * #lazy_builder callback for testBubblingWithPrerender().
     */
    public static function bubblingPlaceholder($foo, $baz) {
        return [
            '#markup' => 'Placeholder!' . $foo . $baz,
        ];
    }
    
    /**
     * #pre_render callback for testOverWriteCacheKeys().
     */
    public static function bubblingCacheOverwritePrerender($elements) {
        // Overwrite the #cache entry with new data.
        $elements['#cache'] = [
            'keys' => [
                'llama',
                'foo',
            ],
        ];
        $elements['#markup'] = 'Setting cache keys just now!';
        return $elements;
    }
    
    /**
     * {@inheritdoc}
     */
    public static function trustedCallbacks() {
        return [
            'bubblingPreRender',
            'bubblingNestedPreRenderUncached',
            'bubblingNestedPreRenderCached',
            'bubblingPlaceholder',
            'bubblingCacheOverwritePrerender',
        ];
    }

}

Members

Title Sort descending Deprecated Modifiers Object type Summary Overriden Title
BubblingTest::bubblingCacheOverwritePrerender public static function #pre_render callback for testOverWriteCacheKeys().
BubblingTest::bubblingNestedPreRenderCached public static function #pre_render callback for testBubblingWithPrerender().
BubblingTest::bubblingNestedPreRenderUncached public static function #pre_render callback for testBubblingWithPrerender().
BubblingTest::bubblingPlaceholder public static function #lazy_builder callback for testBubblingWithPrerender().
BubblingTest::bubblingPreRender public static function #pre_render callback for testBubblingWithPrerender().
BubblingTest::trustedCallbacks public static function Overrides TrustedCallbackInterface::trustedCallbacks
TrustedCallbackInterface::THROW_EXCEPTION constant Untrusted callbacks throw exceptions.
TrustedCallbackInterface::TRIGGER_SILENCED_DEPRECATION constant Untrusted callbacks trigger silenced E_USER_DEPRECATION errors.
TrustedCallbackInterface::TRIGGER_WARNING Deprecated constant Untrusted callbacks trigger E_USER_WARNING errors.

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