You are here

function commerce_wishlist_update_8301 in Commerce Wishlist 8.3

Update entity keys for wishlist.

File

./commerce_wishlist.install, line 24
Contains install and update functions for Commerce Wishlist.

Code

function commerce_wishlist_update_8301() {
  $definition_update_manager = \Drupal::entityDefinitionUpdateManager();
  $entity_type_id = 'commerce_wishlist';
  $uid_storage_definition = $definition_update_manager
    ->getFieldStorageDefinition('uid', $entity_type_id);
  $entity_type = $definition_update_manager
    ->getEntityType($entity_type_id);
  $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);
}