You are here

function entity_test_entity_view_mode_info_alter in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/system/tests/modules/entity_test/entity_test.module \entity_test_entity_view_mode_info_alter()

Implements hook_entity_view_mode_info_alter().

File

core/modules/system/tests/modules/entity_test/entity_test.module, line 207
Test module for the entity API providing several entity types for testing.

Code

function entity_test_entity_view_mode_info_alter(&$view_modes) {
  $entity_info = \Drupal::entityManager()
    ->getDefinitions();
  foreach ($entity_info as $entity_type => $info) {
    if ($entity_info[$entity_type]
      ->getProvider() == 'entity_test' && !isset($view_modes[$entity_type])) {
      $view_modes[$entity_type] = array(
        'full' => array(
          'label' => t('Full object'),
          'status' => TRUE,
          'cache' => TRUE,
        ),
        'teaser' => array(
          'label' => t('Teaser'),
          'status' => TRUE,
          'cache' => TRUE,
        ),
      );
    }
  }
}