Mercurial > hg > cmmr2012-drupal-site
diff core/modules/comment/comment.install @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | a9cd425dd02b |
children |
line wrap: on
line diff
--- a/core/modules/comment/comment.install Thu Feb 28 13:11:55 2019 +0000 +++ b/core/modules/comment/comment.install Thu May 09 15:34:47 2019 +0100 @@ -207,3 +207,30 @@ $field_storage_definition->setDefaultValueCallback(Comment::class . '::getDefaultHostname'); $entity_definition_update_manager->updateFieldStorageDefinition($field_storage_definition); } + +/** + * Set the 'owner' entity key and update the field. + */ +function comment_update_8700() { + $definition_update_manager = \Drupal::entityDefinitionUpdateManager(); + $entity_type = $definition_update_manager->getEntityType('comment'); + $keys = $entity_type->getKeys(); + $keys['owner'] = 'uid'; + $entity_type->set('entity_keys', $keys); + $definition_update_manager->updateEntityType($entity_type); + $definition_update_manager->updateFieldStorageDefinition($definition_update_manager->getFieldStorageDefinition('uid', 'comment')); +} + +/** + * Make the 'entity_type' and 'field_name' comment fields required. + */ +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); +}