function node_entity_display_alter

Implements hook_entity_display_alter().

File

drupal/core/modules/node/node.module, line 200
The core module that allows content to be submitted to the site.

Code

function node_entity_display_alter(EntityDisplay $display, $context) {

  // Hide field labels in 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);
      }
    }
  }
}