function RenderCache::get

Same name in other branches
  1. 9 core/lib/Drupal/Core/Render/RenderCache.php \Drupal\Core\Render\RenderCache::get()
  2. 8.9.x core/lib/Drupal/Core/Render/RenderCache.php \Drupal\Core\Render\RenderCache::get()
  3. 11.x core/lib/Drupal/Core/Render/RenderCache.php \Drupal\Core\Render\RenderCache::get()
1 call to RenderCache::get()
PlaceholderingRenderCache::get in core/lib/Drupal/Core/Render/PlaceholderingRenderCache.php
1 method overrides RenderCache::get()
PlaceholderingRenderCache::get in core/lib/Drupal/Core/Render/PlaceholderingRenderCache.php

File

core/lib/Drupal/Core/Render/RenderCache.php, line 61

Class

RenderCache
Wraps the caching logic for the render caching system.

Namespace

Drupal\Core\Render

Code

public function get(array $elements) {
    if (!$this->isElementCacheable($elements)) {
        return FALSE;
    }
    $bin = $elements['#cache']['bin'] ?? 'render';
    if (($cache_bin = $this->cacheFactory
        ->get($bin)) && ($cache = $cache_bin->get($elements['#cache']['keys'], CacheableMetadata::createFromRenderArray($elements)))) {
        if (!$this->requestStack
            ->getCurrentRequest()
            ->isMethodCacheable()) {
            if (!empty(array_filter($cache->tags, fn(string $tag) => str_starts_with($tag, 'CACHE_MISS_IF_UNCACHEABLE_HTTP_METHOD:')))) {
                return FALSE;
            }
        }
        return $cache->data;
    }
    return FALSE;
}

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