You are here

function commerce_payment_update_8203 in Commerce Core 8.2

Update entity keys for payment methods.

File

modules/payment/commerce_payment.install, line 81
Install, update and uninstall functions for the commerce_payment module.

Code

function commerce_payment_update_8203() {
  $definition_update_manager = \Drupal::entityDefinitionUpdateManager();
  $uid_storage_definition = $definition_update_manager
    ->getFieldStorageDefinition('uid', 'commerce_payment_method');
  $entity_type = $definition_update_manager
    ->getEntityType('commerce_payment_method');
  $keys = $entity_type
    ->getKeys();
  $keys['owner'] = 'uid';
  $keys['uid'] = 'uid';
  $entity_type
    ->set('entity_keys', $keys);
  $definition_update_manager
    ->updateEntityType($entity_type);
  $definition_update_manager
    ->updateFieldStorageDefinition($uid_storage_definition);
}