You are here

function apigee_edge_update_8102 in Apigee Edge 8

Update the field storage definitions for first_name and last_name fields.

File

./apigee_edge.install, line 263
Copyright 2018 Google Inc.

Code

function apigee_edge_update_8102() {
  $entity_type_id = 'user';
  $fields = [
    'first_name',
    'last_name',
  ];

  /** @var \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager */
  $entity_field_manager = Drupal::service('entity_field.manager');

  /** @var \Drupal\Core\Entity\EntityLastInstalledSchemaRepositoryInterface $last_installed_schema_repository */
  $last_installed_schema_repository = \Drupal::service('entity.last_installed_schema.repository');
  $field_definitions = $entity_field_manager
    ->getFieldStorageDefinitions($entity_type_id);
  $original_storage_definitions = $last_installed_schema_repository
    ->getLastInstalledFieldStorageDefinitions($entity_type_id);
  foreach ($fields as $field) {
    $original_storage_definitions[$field] = $field_definitions[$field];
  }

  // The schema updates are already handled in apigee_edge_update_8101().
  // This updates the last installed definition.
  $last_installed_schema_repository
    ->setLastInstalledFieldStorageDefinitions($entity_type_id, $original_storage_definitions);
}