diff --git a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php index a517735..f128ade 100644 --- a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php +++ b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php @@ -231,7 +231,7 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la // Set build defaults. $build_list[$key] = $this->getBuildDefaults($entity, $view_mode, $langcode); $entityType = $this->entityTypeId; - $this->moduleHandler()->alter(array($entityType . '_defaults', 'entity_defaults'), $build_list[$key], $entity, $view_mode, $langcode); + $this->moduleHandler()->alter(array($entityType . '_build_defaults', 'entity_build_defaults'), $build_list[$key], $entity, $view_mode, $langcode); $build_list[$key]['#weight'] = $weight++; } diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 76370ec..c8ad565 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -360,9 +360,9 @@ function comment_new_page_count($num_comments, $new_replies, EntityInterface $en } /** - * Implements hook_entity_defaults_alter(). + * Implements hook_entity_build_defaults_alter(). */ -function comment_entity_defaults_alter(array &$build, EntityInterface $entity, $view_mode = 'full', $langcode = NULL) { +function comment_entity_build_defaults_alter(array &$build, EntityInterface $entity, $view_mode = 'full', $langcode = NULL) { // Get the corresponding display settings. $display = EntityViewDisplay::collectRenderDisplay($entity, $view_mode); // Add the comment page number to the cache key if render caching is enabled. diff --git a/core/modules/node/tests/modules/node_test/node_test.module b/core/modules/node/tests/modules/node_test/node_test.module index ad12157..58624c3 100644 --- a/core/modules/node/tests/modules/node_test/node_test.module +++ b/core/modules/node/tests/modules/node_test/node_test.module @@ -39,9 +39,9 @@ function node_test_node_view(array &$build, NodeInterface $node, EntityViewDispl } /** - * Implements hook_node_defaults_alter(). + * Implements hook_ENTITY_TYPE_build_defaults_alter(). */ -function node_test_node_defaults_alter(array &$build, NodeInterface &$node, $view_mode = 'full', $langcode = NULL) { +function node_test_node_build_defaults_alter(array &$build, NodeInterface &$node, $view_mode = 'full', $langcode = NULL) { if ($view_mode == 'rss') { $node->rss_namespaces['xmlns:drupaltest'] = 'http://example.com/test-namespace'; } diff --git a/core/modules/system/entity.api.php b/core/modules/system/entity.api.php index a24e13a..f2e989c 100644 --- a/core/modules/system/entity.api.php +++ b/core/modules/system/entity.api.php @@ -563,6 +563,54 @@ function hook_entity_view_mode_alter(&$view_mode, Drupal\Core\Entity\EntityInter } /** + * Alters entity renderable values before cache checking in drupal_render(). + * + * Invoked for a specific entity type. + * + * 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. + * + * @param array &$build + * A renderable array containing the entity's caching and view mode values. + * @param \Drupal\Core\Entity\EntityInterface $entity + * The entity that is being viewed. + * @param string $view_mode + * The view_mode that is to be used to display the entity. + * @param string $langcode + * The code of the language $entity is accessed in. + * + * @see drupal_render() + * @see \Drupal\Core\Entity\EntityViewBuilder + */ +function hook_ENTITY_TYPE_build_defaults_alter(array &$build, \Drupal\Core\Entity\EntityInterface $entity, $view_mode, $langcode) { + +} + +/** + * Alters entity renderable values before cache checking in drupal_render(). + * + * 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. + * + * @param array &$build + * A renderable array containing the entity's caching and view mode values. + * @param \Drupal\Core\Entity\EntityInterface $entity + * The entity that is being viewed. + * @param string $view_mode + * The view_mode that is to be used to display the entity. + * @param string $langcode + * The code of the language $entity is accessed in. + * + * @see drupal_render() + * @see \Drupal\Core\Entity\EntityViewBuilder + */ +function hook_entity_build_defaults_alter(array &$build, \Drupal\Core\Entity\EntityInterface $entity, $view_mode, $langcode) { + +} + +/** * Alters the settings used for displaying an entity. * * @param \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display