function opigno_learning_path_update_8010 in Opigno Learning path 8
Creates required trainings field in the learning path group type.
File
- ./
opigno_learning_path.install, line 328 - Install, update and uninstall functions for the module.
Code
function opigno_learning_path_update_8010() {
$config_path = drupal_get_path('module', 'opigno_learning_path') . '/config/install';
$storage = new FileStorage($config_path);
$data = $storage
->read('field.storage.group.field_required_trainings');
if (!FieldStorageConfig::loadByName($data['entity_type'], $data['field_name'])) {
FieldStorageConfig::create($data)
->save();
}
$data = $storage
->read('field.field.group.learning_path.field_required_trainings');
if (!FieldConfig::loadByName($data['entity_type'], $data['bundle'], $data['field_name'])) {
FieldConfig::create($data)
->save();
}
/* @var Drupal\Core\Config\CachedStorage $config_storage */
$config_storage = \Drupal::service('config.storage');
$configs = [
'core.entity_form_display.group.learning_path.default',
'core.entity_view_display.group.learning_path.default',
];
foreach ($configs as $item) {
$data = $storage
->read($item);
$config_storage
->write($item, $data);
}
}