function NodeViewBuilder::getBuildDefaults

Same name in other branches
  1. 9 core/modules/node/src/NodeViewBuilder.php \Drupal\node\NodeViewBuilder::getBuildDefaults()
  2. 8.9.x core/modules/node/src/NodeViewBuilder.php \Drupal\node\NodeViewBuilder::getBuildDefaults()
  3. 11.x core/modules/node/src/NodeViewBuilder.php \Drupal\node\NodeViewBuilder::getBuildDefaults()

Overrides EntityViewBuilder::getBuildDefaults

File

core/modules/node/src/NodeViewBuilder.php, line 60

Class

NodeViewBuilder
View builder handler for nodes.

Namespace

Drupal\node

Code

protected function getBuildDefaults(EntityInterface $entity, $view_mode) {
    $defaults = parent::getBuildDefaults($entity, $view_mode);
    // Don't cache nodes that are in 'preview' mode.
    if (isset($defaults['#cache']) && isset($entity->in_preview)) {
        unset($defaults['#cache']);
    }
    return $defaults;
}

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