function social_event_update_8916 in Open Social 10.3.x
Same name and namespace in other branches
- 10.2.x modules/social_features/social_event/social_event.install \social_event_update_8916()
Add the 'enable event enrolment' field.
File
- modules/
social_features/ social_event/ social_event.install, line 1805 - Install, update and uninstall functions for the social_event module.
Code
function social_event_update_8916() {
$config_path = drupal_get_path('module', 'social_event') . '/config/static';
$source = new FileStorage($config_path);
$entity_type_manager = \Drupal::entityTypeManager();
/** @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $field_storage_config_storage */
$field_storage_config_storage = $entity_type_manager
->getStorage('field_storage_config');
// Create field storages.
$field_type_manager = \Drupal::service('plugin.manager.field.field_type');
$data = $source
->read('field.storage.node.field_event_enable_enrollment_8916');
$class = $field_type_manager
->getPluginClass($data['type']);
if (is_null($field_storage_config_storage
->load($data['id']))) {
$data['settings'] = $class::storageSettingsFromConfigData($data['settings']);
$field_storage_config_storage
->create($data)
->save();
}
/** @var \Drupal\Core\Config\Entity\ConfigEntityStorageInterface $field_config_storage */
$field_config_storage = $entity_type_manager
->getStorage('field_config');
// Create field settings.
$data = $source
->read('field.field.node.event.field_event_enable_enrollment_8916');
if (is_null($field_config_storage
->load($data['id']))) {
$field_config_storage
->create($data)
->save();
}
}