Alters the settings used for displaying an entity.
\Drupal\entity\Plugin\Core\Entity\EntityDisplay $display: The entity_display object that will be used to display the entity components.
array $context: An associative array containing:
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
function hook_entity_display_alter(\Drupal\entity\Plugin\Core\Entity\EntityDisplay $display, array $context) {
// Leave field labels out of the search index.
if ($context['entity_type'] == 'node' && $context['view_mode'] == 'search_index') {
foreach ($display
->getComponents() as $name => $options) {
if (isset($options['label'])) {
$options['label'] = 'hidden';
$display
->setComponent($name, $options);
}
}
}
}