Issue #3193131 by Matroskeen, daffie, catch: $context in hook_entity_view_mode_alter is always empty
parent
f049151212
commit
f58b01f2e5
|
@ -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';
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue