function hook_entity_build_defaults_alter

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_build_defaults_alter()
  2. 10 core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_build_defaults_alter()
  3. 11.x core/lib/Drupal/Core/Entity/entity.api.php \hook_entity_build_defaults_alter()

Alter entity renderable values before cache checking during rendering.

The values in the #cache key of the renderable array are used to determine if a cache entry exists for the entity's rendered output. Ideally only values that pertain to caching should be altered in this hook.

Parameters

array &$build: A renderable array containing the entity's caching and view mode values.

\Drupal\Core\Entity\EntityInterface $entity: The entity that is being viewed.

string $view_mode: The view_mode that is to be used to display the entity.

See also

\Drupal\Core\Render\RendererInterface::render()

\Drupal\Core\Entity\EntityViewBuilder

hook_ENTITY_TYPE_build_defaults_alter()

Related topics

1 function implements hook_entity_build_defaults_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

layout_builder_entity_build_defaults_alter in core/modules/layout_builder/layout_builder.module
Implements hook_entity_build_defaults_alter().

File

core/lib/Drupal/Core/Entity/entity.api.php, line 1750

Code

function hook_entity_build_defaults_alter(array &$build, \Drupal\Core\Entity\EntityInterface $entity, $view_mode) {
}

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