function EntityTestHooks::entityViewModeInfoAlter
Implements hook_entity_view_mode_info_alter().
File
-
core/
modules/ system/ tests/ modules/ entity_test/ src/ Hook/ EntityTestHooks.php, line 159
Class
- EntityTestHooks
- Hook implementations for entity_test.
Namespace
Drupal\entity_test\HookCode
public function entityViewModeInfoAlter(&$view_modes) {
$entity_info = \Drupal::entityTypeManager()->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] = [
'full' => [
'label' => t('Full object'),
'status' => TRUE,
'cache' => TRUE,
],
'teaser' => [
'label' => t('Teaser'),
'status' => TRUE,
'cache' => TRUE,
],
];
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.