Change record status: 
Introduced in branch: 
Introduced in version: 

In Drupal 7, field_bundle_settings() was the main entry to figure out whether a view mode was enabled or not. It was also used to update the view mode settings per entity type and bundle.

In Drupal 8, this information is now stored in the EntityViewDisplay config entity for the view mode, which also holds the display configuration for the various components of an entity (e.g. formatter and formatter settings for each field), and can be accessed with the entity_get_display() function. The field_bundle_settings() function, and the field_view_mode_settings() shortcut, have been removed.

If the 'status' property of the entity display object for the view mode is TRUE, that display will be used when rendering an entity in the view mode, otherwise the display for the 'default' view mode will be used. That logic is enclosed in the EntityViewDisplay::collectRenderDisplays() method, that is used by rendering code.

See the following change record for more information about EntityViewDisplay objects : Introduced EntityViewDisplay config entities.

Sample code

Drupal 7:

// Get the configuration of the view mode for the entity type and bundle.
$bundle_settings = field_bundle_settings($entity_type, $bundle);
// If disabled, enable it and save the settings back.
if (empty($bundle_settings['view_modes'][$view_mode]['status']) {
  $bundle_settings['view_modes'][$view_mode]['status'] = TRUE;
  field_bundle_settings($entity_type, $bundle, $bundle_settings)

Drupal 8:

// Get the EntityViewDisplay for the view mode.
$display = entity_get_display($entity_type, $bundle, $view_mode);
// If disabled, enable it and save it back.
if (!$display->status()) {
  $display->set('status', TRUE);
Module developers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other updates done