function node_test_entity_view_mode_alter

Same name in other branches
  1. 7.x modules/node/tests/node_test.module \node_test_entity_view_mode_alter()
  2. 9 core/modules/node/tests/modules/node_test/node_test.module \node_test_entity_view_mode_alter()
  3. 8.9.x core/modules/node/tests/modules/node_test/node_test.module \node_test_entity_view_mode_alter()
  4. 10 core/modules/node/tests/modules/node_test/node_test.module \node_test_entity_view_mode_alter()

Implements hook_entity_view_mode_alter().

File

core/modules/node/tests/modules/node_test/node_test.module, line 159

Code

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) {
        $view_mode = $change_view_mode;
    }
}

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