You are here

protected function NodeViewBuilder::getBuildDefaults in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/node/src/NodeViewBuilder.php \Drupal\node\NodeViewBuilder::getBuildDefaults()

Provides entity-specific defaults to the build process.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity for which the defaults should be provided.

string $view_mode: The view mode that should be used.

Return value

array

Overrides EntityViewBuilder::getBuildDefaults

File

core/modules/node/src/NodeViewBuilder.php, line 62
Contains \Drupal\node\NodeViewBuilder.

Class

NodeViewBuilder
Render controller 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;
}