public function Drupal7Backend::language_writeToDatabase in Configuration Management 7.3
Overrides BackendInterface::language_writeToDatabase
File
- src/
Backends/ Drupal7Backend.php, line 173
Class
Namespace
Configuration\BackendsCode
public function language_writeToDatabase($language) {
$current_language = db_select('languages')
->condition('language', $language->language)
->fields('languages')
->execute()
->fetchAssoc();
// Set the default language when needed.
$default = language_default();
// Insert new language via api function.
if (empty($current_language)) {
locale_add_language($language->language, $language->name, $language->native, $language->direction, $language->domain, $language->prefix, $language->enabled, $language->language == $default->language);
// Additional params, locale_add_language does not implement.
db_update('languages')
->fields(array(
'plurals' => empty($language->plurals) ? 0 : $language->plurals,
'formula' => empty($language->formula) ? '' : $language->formula,
))
->condition('language', $language->language)
->execute();
}
else {
$schema = drupal_get_schema('languages');
$properties = array_keys($schema['fields']);
// The javascript hash is not in the imported data but should be empty
if (!isset($language->javascript)) {
$language->javascript = '';
}
$fields = array_intersect_key((array) $language, array_flip($properties));
db_update('languages')
->fields($fields)
->condition('language', $language->language)
->execute();
// Set the default language when needed.
$default = language_default();
if ($default->language == $language->language) {
variable_set('language_default', (object) $fields);
}
}
}