function translation_entity_save_settings

Stores entity translation settings.

Parameters

array $settings: An associative array of settings keyed by entity type and bundle. At bundle level the following keys are available:

  • translatable: The bundle translatability status, which is a bool.
  • settings: An array of language configuration settings as defined by language_save_default_configuration().
  • fields: An associative array with field names as keys and a boolean as value, indicating field translatability.
  • columns: An associative array of translation synchronization settings keyed by field names.
1 string reference to 'translation_entity_save_settings'
_translation_entity_update_field_translatability in drupal/core/modules/translation_entity/translation_entity.admin.inc
Stores entity translation settings.

File

drupal/core/modules/translation_entity/translation_entity.module, line 1010
Allows entities to be translated into different languages.

Code

function translation_entity_save_settings($settings) {
  foreach ($settings as $entity_type => $entity_settings) {
    foreach ($entity_settings as $bundle => $bundle_settings) {

      // The 'translatable' value is set only if it is possible to enable.
      if (isset($bundle_settings['translatable'])) {

        // Store whether a bundle has translation enabled or not.
        translation_entity_set_config($entity_type, $bundle, 'enabled', $bundle_settings['translatable']);

        // Store whether fields have translation enabled or not.
        if (!empty($bundle_settings['columns'])) {
          foreach ($bundle_settings['columns'] as $field_name => $column_settings) {
            $field = field_info_field($field_name);
            $instance = field_info_instance($entity_type, $field_name, $bundle);
            if ($field['translatable']) {
              $instance['settings']['translation_sync'] = $column_settings;
            }
            else {
              unset($instance['settings']['translation_sync']);
            }
            field_update_instance($instance);
          }
        }
      }
    }
  }

  // Ensure entity and menu router information are correctly rebuilt.
  entity_info_cache_clear();
  menu_router_rebuild();
}