1 field.module field_entity_view_mode_delete($view_mode, $entity_type)

Implements hook_entity_view_mode_delete().

File

core/modules/field/field.module, line 1415
Attach custom data fields to Backdrop entities.

Code

function field_entity_view_mode_delete($view_mode, $entity_type) {
  $entity_info = entity_get_info($entity_type);
  $view_mode_name = $view_mode['machine_name'];

  foreach (array_keys($entity_info['bundles']) as $bundle) {
    // Remove all field bundle settings for the deleted display mode.
    $settings = field_bundle_settings($entity_type, $bundle);
    if (isset($settings['view_modes'][$view_mode_name]) || isset($settings['extra_fields']['display'][$view_mode_name])) {
      unset($settings['view_modes'][$view_mode_name]);
      unset($settings['extra_fields']['display'][$view_mode_name]);
      field_bundle_settings($entity_type, $bundle, $settings);
    }

    // Remove all field instance display settings for the deleted display mode.
    $instances = field_read_instances(array('entity_type' => $entity_type, 'bundle' => $bundle));
    foreach ($instances as $instance) {
      // Remove the display mode settings from all configured field instances.
      if (isset($instance['display'][$view_mode_name])) {
        unset($instance['display'][$view_mode_name]);
        field_update_instance($instance);
      }
    }
  }
}