You are here

function comment_update_8701 in Drupal 8

Make the 'entity_type' and 'field_name' comment fields required.

File

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

Code

function comment_update_8701() {
  $definition_update_manager = \Drupal::entityDefinitionUpdateManager();
  $field_definition = $definition_update_manager
    ->getFieldStorageDefinition('entity_type', 'comment');
  $field_definition
    ->setRequired(TRUE);
  $definition_update_manager
    ->updateFieldStorageDefinition($field_definition);
  $field_definition = $definition_update_manager
    ->getFieldStorageDefinition('field_name', 'comment');
  $field_definition
    ->setRequired(TRUE);
  $definition_update_manager
    ->updateFieldStorageDefinition($field_definition);
}