function field_entity_view_mode_update in Entity view modes 7
Implements hook_entity_view_mode_update() on behalf of core field module.
1 call to field_entity_view_mode_update()
- field_entity_view_mode_insert in ./
entity_view_mode.module - Implements hook_entity_view_mode_insert() on behalf of core field module.
File
- ./
entity_view_mode.module, line 256
Code
function field_entity_view_mode_update($view_mode, $entity_type) {
module_load_include('inc', 'field_ui', 'field_ui.admin');
$entity_info = entity_get_info($entity_type);
$view_mode_name = $view_mode['machine_name'];
// If custom settings is set to false, then we should be disabling this view
// view mode for all bundles.
//if (empty($view_mode['custom settings'])) {
// $view_mode['enabled_bundles'] = array_fill_keys(array_keys($entity_info['bundles']), 0);
//}
if (!empty($view_mode['enabled_bundles'])) {
foreach ($view_mode['enabled_bundles'] as $bundle => $value) {
$bundle_settings = field_bundle_settings($entity_type, $bundle);
// Display a message for each view mode newly configured to use custom
// settings.
$view_mode_settings = field_view_mode_settings($entity_type, $bundle);
if (!empty($value) && empty($view_mode_settings[$view_mode_name]['custom_settings'])) {
$path = _field_ui_bundle_admin_path($entity_type, $bundle) . "/display/{$view_mode_name}";
drupal_set_message(t('The %view_mode @entity_type @bundle view mode now uses custom display settings copied from the default view mode. You might want to <a href="@url">configure them</a>.', array(
'%view_mode' => $view_mode['label'],
'@entity_type' => $entity_info['label'],
'@bundle' => $entity_info['bundles'][$bundle]['label'],
'@url' => url($path, array(
'query' => drupal_get_destination(),
)),
)));
// Initialize the newly customized view mode with the display settings
// from the default view mode.
_field_ui_add_default_view_mode_settings($entity_type, $bundle, $view_mode_name, $bundle_settings);
}
// Save updated bundle settings.
$bundle_settings['view_modes'][$view_mode_name]['custom_settings'] = !empty($value);
field_bundle_settings($entity_type, $bundle, $bundle_settings);
}
}
}