function block_content_update_10200

Remove the unique values constraint from block content info fields.

File

core/modules/block_content/block_content.install, line 43

Code

function block_content_update_10200() {
  $constraint = 'UniqueField';
  $definition_update_manager = \Drupal::entityDefinitionUpdateManager();
  $field_storage_definition = $definition_update_manager->getFieldStorageDefinition('info', 'block_content');
  $constraints = $field_storage_definition->getConstraints();
  if (isset($constraints[$constraint])) {
    unset($constraints[$constraint]);
    $field_storage_definition->setConstraints($constraints);
    $definition_update_manager->updateFieldStorageDefinition($field_storage_definition);
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.