You are here

function social_event_type_update_8901 in Open Social 10.3.x

Same name and namespace in other branches
  1. 10.0.x modules/social_features/social_event/modules/social_event_type/social_event_type.install \social_event_type_update_8901()
  2. 10.1.x modules/social_features/social_event/modules/social_event_type/social_event_type.install \social_event_type_update_8901()
  3. 10.2.x modules/social_features/social_event/modules/social_event_type/social_event_type.install \social_event_type_update_8901()

Update label for field_event_type field.

File

modules/social_features/social_event/modules/social_event_type/social_event_type.install, line 58
Install, update and uninstall functions for the social_event_type module.

Code

function social_event_type_update_8901() {

  // Load the existing configuration.
  $config_name = 'field.field.node.event.field_event_type';
  $config = \Drupal::configFactory()
    ->getEditable($config_name);
  $config_data = $config
    ->getRawData();
  if (!empty($config_data['label'])) {

    // This to ensure any custom added values are not affected.
    if (strpos($config_data['label'], 'Event type') !== FALSE) {
      $config_data['label'] = 'Type';
    }
    $config
      ->setData($config_data)
      ->save();

    // Make sure we clear cached definitions for the fields.
    \Drupal::service('entity_field.manager')
      ->clearCachedFieldDefinitions();
  }
}