Issue #3193131 by Matroskeen, daffie, catch: $context in hook_entity_view_mode_alter is always empty

merge-requests/268/head
catch 2021-01-22 17:24:33 +00:00
parent f049151212
commit f58b01f2e5
2 changed files with 2 additions and 5 deletions

View File

@ -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';

View File

@ -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) {