You are here

function opigno_class_update_8001 in Opigno class 8

Create new field in opigno_class group type.

File

./opigno_class.install, line 15
Install, update and uninstall functions for the Opigno Class module.

Code

function opigno_class_update_8001() {
  $config_path = drupal_get_path('module', 'opigno_class') . '/config/install';
  $storage = new FileStorage($config_path);
  $data = $storage
    ->read('field.storage.group.field_class_media_image');
  if (!FieldStorageConfig::loadByName($data['entity_type'], $data['field_name'])) {
    FieldStorageConfig::create($data)
      ->save();
  }
  $data = $storage
    ->read('field.field.group.opigno_class.field_class_media_image');
  if (!FieldConfig::loadByName($data['entity_type'], $data['bundle'], $data['field_name'])) {
    FieldConfig::create($data)
      ->save();
  }
}