function NodeTestHooks::entityViewModeAlter

Implements hook_entity_view_mode_alter().

File

core/modules/node/tests/modules/node_test/src/Hook/NodeTestHooks.php, line 167

Class

NodeTestHooks
Hook implementations for node_test.

Namespace

Drupal\node_test\Hook

Code

public function entityViewModeAlter(&$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.