function EntityViewBuilder::isViewModeCacheable

Same name in other branches
  1. 9 core/lib/Drupal/Core/Entity/EntityViewBuilder.php \Drupal\Core\Entity\EntityViewBuilder::isViewModeCacheable()
  2. 8.9.x core/lib/Drupal/Core/Entity/EntityViewBuilder.php \Drupal\Core\Entity\EntityViewBuilder::isViewModeCacheable()
  3. 11.x core/lib/Drupal/Core/Entity/EntityViewBuilder.php \Drupal\Core\Entity\EntityViewBuilder::isViewModeCacheable()

Determines whether the view mode is cacheable.

Parameters

string $view_mode: Name of the view mode that should be rendered.

Return value

bool TRUE if the view mode can be cached, FALSE otherwise.

1 call to EntityViewBuilder::isViewModeCacheable()
EntityViewBuilder::getBuildDefaults in core/lib/Drupal/Core/Entity/EntityViewBuilder.php
Provides entity-specific defaults to the build process.

File

core/lib/Drupal/Core/Entity/EntityViewBuilder.php, line 435

Class

EntityViewBuilder
Base class for entity view builders.

Namespace

Drupal\Core\Entity

Code

protected function isViewModeCacheable($view_mode) {
    if ($view_mode == 'default') {
        // The 'default' is not an actual view mode.
        return TRUE;
    }
    $view_modes_info = $this->entityDisplayRepository
        ->getViewModes($this->entityTypeId);
    return !empty($view_modes_info[$view_mode]['cache']);
}

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