From f58b01f2e59d8f82be16d06ef377bbb23456f3bc Mon Sep 17 00:00:00 2001 From: catch Date: Fri, 22 Jan 2021 17:24:33 +0000 Subject: [PATCH] Issue #3193131 by Matroskeen, daffie, catch: $context in hook_entity_view_mode_alter is always empty --- core/lib/Drupal/Core/Entity/entity.api.php | 5 +---- core/modules/node/tests/modules/node_test/node_test.module | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/core/lib/Drupal/Core/Entity/entity.api.php b/core/lib/Drupal/Core/Entity/entity.api.php index b84ec3657cb..d474ebdc8eb 100644 --- a/core/lib/Drupal/Core/Entity/entity.api.php +++ b/core/lib/Drupal/Core/Entity/entity.api.php @@ -1648,13 +1648,10 @@ function hook_entity_prepare_view($entity_type_id, array $entities, array $displ * The view_mode that is to be used to display the entity. * @param \Drupal\Core\Entity\EntityInterface $entity * The entity that is being viewed. - * @param array $context - * Array with additional context information, currently only contains the - * langcode the entity is viewed in. * * @ingroup entity_crud */ -function hook_entity_view_mode_alter(&$view_mode, Drupal\Core\Entity\EntityInterface $entity, $context) { +function hook_entity_view_mode_alter(&$view_mode, Drupal\Core\Entity\EntityInterface $entity) { // For nodes, change the view mode when it is teaser. if ($entity->getEntityTypeId() == 'node' && $view_mode == 'teaser') { $view_mode = 'my_custom_view_mode'; 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 5fb84eb8199..4054362e456 100644 --- a/core/modules/node/tests/modules/node_test/node_test.module +++ b/core/modules/node/tests/modules/node_test/node_test.module @@ -153,7 +153,7 @@ function node_test_node_update(NodeInterface $node) { /** * Implements hook_entity_view_mode_alter(). */ -function node_test_entity_view_mode_alter(&$view_mode, EntityInterface $entity, $context) { +function node_test_entity_view_mode_alter(&$view_mode, EntityInterface $entity) { // Only alter the view mode if we are on the test callback. $change_view_mode = \Drupal::state()->get('node_test_change_view_mode', ''); if ($change_view_mode) {