function DevelEntityTestHooks::entityViewModeInfoAlter
Implements hook_entity_view_mode_info_alter().
Attributes
#[Hook('entity_view_mode_info_alter')]
File
-
tests/
modules/ devel_entity_test/ src/ Hook/ DevelEntityTestHooks.php, line 23
Class
- DevelEntityTestHooks
- Hook implementations for devel_entity_test.
Namespace
Drupal\devel_entity_test\HookCode
public function entityViewModeInfoAlter(array &$view_modes) : void {
$entity_info = $this->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' => $this->t('Full object'),
'status' => TRUE,
'cache' => TRUE,
],
'teaser' => [
'label' => $this->t('Teaser'),
'status' => TRUE,
'cache' => TRUE,
],
];
}
}