function bibcite_entity_update_8007 in Bibliography & Citation 8
Same name and namespace in other branches
- 2.0.x modules/bibcite_entity/bibcite_entity.install \bibcite_entity_update_8007()
Fix missed bibcite reference view modes configurations.
File
- modules/
bibcite_entity/ bibcite_entity.install, line 257 - Module installation hooks implementation.
Code
function bibcite_entity_update_8007() {
$config_factory = \Drupal::configFactory();
$install_path = __DIR__ . '/config/optional/';
$citation_file_list = glob($install_path . 'core.entity_view_display.bibcite_reference*');
$config_list = array_map(function ($file) {
return basename($file, '.yml');
}, $citation_file_list);
foreach ($config_list as $id => $config_name) {
$file_path = $citation_file_list[$id];
if (file_exists($file_path)) {
$config = $config_factory
->getEditable($config_name);
// Save config if not exist.
if ($config
->isNew()) {
$content = file_get_contents($file_path);
$yaml = Yaml::parse($content);
foreach ($yaml as $key => $value) {
$config
->set($key, $value);
}
$config
->save(TRUE);
}
}
}
}