function EntityTestHooks::entityTestViewModeAlter

Same name and namespace in other branches
  1. 11.x core/modules/system/tests/modules/entity_test/src/Hook/EntityTestHooks.php \Drupal\entity_test\Hook\EntityTestHooks::entityTestViewModeAlter()

Implements hook_ENTITY_TYPE_view_mode_alter().

Attributes

#[Hook('entity_test_view_mode_alter')]

File

core/modules/system/tests/modules/entity_test/src/Hook/EntityTestHooks.php, line 217

Class

EntityTestHooks
Hook implementations for entity_test.

Namespace

Drupal\entity_test\Hook

Code

public function entityTestViewModeAlter(string &$view_mode, EntityInterface $entity) : void {
  if ($view_mode == 'entity_test.vm_alter_test') {
    $view_mode = 'entity_test.vm_alter_full';
  }
}

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