You are here

function opigno_ilt_update_8001 in Opigno Instructor-led Trainings 8

Creates the ILT calendar event type.

File

./opigno_ilt.install, line 41
Install, update and uninstall functions for the Opigno ILT module.

Code

function opigno_ilt_update_8001() {
  $config_path = drupal_get_path('module', 'opigno_ilt') . '/config/install';
  $storage = new FileStorage($config_path);
  $config_storage = \Drupal::service('config.storage');
  $data = $storage
    ->read('opigno_calendar_event.type.ilt_calendar_event');
  $config_storage
    ->write('opigno_calendar_event.type.ilt_calendar_event', $data);
  $data = $storage
    ->read('field.storage.opigno_calendar_event.field_ilt');
  if (!FieldStorageConfig::loadByName($data['entity_type'], $data['field_name'])) {
    FieldStorageConfig::create($data)
      ->save();
  }
  $data = $storage
    ->read('field.field.opigno_calendar_event.ilt_calendar_event.field_ilt');
  if (!FieldConfig::loadByName($data['entity_type'], $data['bundle'], $data['field_name'])) {
    FieldConfig::create($data)
      ->save();
  }
  $data = $storage
    ->read('field.field.opigno_calendar_event.ilt_calendar_event.field_calendar_event_members');
  if (!FieldConfig::loadByName($data['entity_type'], $data['bundle'], $data['field_name'])) {
    FieldConfig::create($data)
      ->save();
  }
}