You are here

function comment_update_8600 in Drupal 8

Configure the comment hostname base field to use a default value callback.

File

core/modules/comment/comment.install, line 229
Install, update and uninstall functions for the Comment module.

Code

function comment_update_8600() {
  $entity_definition_update_manager = \Drupal::entityDefinitionUpdateManager();

  /** @var \Drupal\Core\Field\BaseFieldDefinition $field_storage_definition */
  $field_storage_definition = $entity_definition_update_manager
    ->getFieldStorageDefinition('hostname', 'comment');
  $field_storage_definition
    ->setDefaultValueCallback(Comment::class . '::getDefaultHostname');
  $entity_definition_update_manager
    ->updateFieldStorageDefinition($field_storage_definition);
}