function CacheTagTest::getRenderCache

Same name in other branches
  1. 9 core/modules/views/tests/src/Functional/Plugin/CacheTagTest.php \Drupal\Tests\views\Functional\Plugin\CacheTagTest::getRenderCache()
  2. 10 core/modules/views/tests/src/Functional/Plugin/CacheTagTest.php \Drupal\Tests\views\Functional\Plugin\CacheTagTest::getRenderCache()
  3. 11.x core/modules/views/tests/src/Functional/Plugin/CacheTagTest.php \Drupal\Tests\views\Functional\Plugin\CacheTagTest::getRenderCache()

Gets the render cache for a given view.

Parameters

\Drupal\views\ViewExecutable $view: The view.

Return value

array|false The render cache result or FALSE if not existent.

1 call to CacheTagTest::getRenderCache()
CacheTagTest::testTagCaching in core/modules/views/tests/src/Functional/Plugin/CacheTagTest.php
Tests the tag cache plugin.

File

core/modules/views/tests/src/Functional/Plugin/CacheTagTest.php, line 109

Class

CacheTagTest
Tests tag cache plugin.

Namespace

Drupal\Tests\views\Functional\Plugin

Code

protected function getRenderCache(ViewExecutable $view) {
    
    /** @var \Drupal\Core\Render\RenderCacheInterface $render_cache */
    $render_cache = \Drupal::service('render_cache');
    $view->element = [
        '#cache' => [],
    ];
    $build = $view->buildRenderable();
    $build['#cache']['contexts'] = Cache::mergeContexts($build['#cache']['contexts'], $this->container
        ->getParameter('renderer.config')['required_cache_contexts']);
    return $render_cache->get($build);
}

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