function devel_entity_test_entity_view_mode_info_alter

Same name in other branches
  1. 4.x tests/modules/devel_entity_test/devel_entity_test.module \devel_entity_test_entity_view_mode_info_alter()

Implements hook_entity_view_mode_info_alter().

File

tests/modules/devel_entity_test/devel_entity_test.module, line 11

Code

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