function bibcite_endnote_update_8001 in Bibliography & Citation 8
Same name and namespace in other branches
- 2.0.x modules/bibcite_endnote/bibcite_endnote.install \bibcite_endnote_update_8001()
Fix Endnote 7 XML format mapping for secondary-title, short-title and translated-title fields.
File
- modules/
bibcite_endnote/ bibcite_endnote.install, line 11 - Module installation hooks implementation.
Code
function bibcite_endnote_update_8001() {
$config = \Drupal::configFactory()
->getEditable('bibcite_entity.mapping.endnote8');
$fields = $config
->get('fields');
// Set mapping for secondary-title field basing on incorrect title-secondary
// field mapping.
$fields['secondary-title'] = isset($fields['title-secondary']) ? $fields['title-secondary'] : '';
unset($fields['title-secondary']);
// Config installed with the module is shipped with correct mapping i.e. it
// sets short-title field mapping. Existing in config title-short field means
// that config was updated using settings form.
if (isset($fields['title-short'])) {
// If title-short mapping was intentionally set to some field, then let's
// use this mapping to restore short-title mapping.
if ($fields['title-short'] !== '') {
$fields['short-title'] = $fields['title-short'];
}
else {
$fields['short-title'] = 'bibcite_short_title';
}
unset($fields['title-short']);
}
// Fix translated-title mapping if default mapping is used which maps to
// non-existing bibcite_translated-title field.
if (isset($fields['translated-title']) && $fields['translated-title'] === 'bibcite_translated-title') {
$fields['translated-title'] = 'bibcite_translated_title';
}
// Save config updates.
$config
->set('fields', $fields);
$config
->save(TRUE);
}