function opigno_class_update_8009 in Opigno class 8
Update Class group structure.
File
- ./
opigno_class.install, line 111 - Install, update and uninstall functions for the Opigno Class module.
Code
function opigno_class_update_8009() {
$config_path = drupal_get_path('module', 'opigno_class') . '/config/install';
$source = new FileStorage($config_path);
$config_storage = \Drupal::service('config.storage');
$config_storage
->write('group.type.opigno_class', $source
->read('group.type.opigno_class'));
$bundles = [
'opigno_class',
];
$fields['field_class_media_image'] = [
'entity_type' => 'group',
];
foreach ($bundles as $bundle) {
foreach ($fields as $field_name => $config) {
$field = FieldConfig::loadByName($config['entity_type'], $bundle, $field_name);
if (!empty($field)) {
$field
->delete();
}
}
}
foreach ($fields as $field_name => $config) {
$field_storage = FieldStorageConfig::loadByName($config['entity_type'], $field_name);
if (!empty($field_storage)) {
$field_storage
->delete();
}
}
}