Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / comment / comment.install
index c244fe4ce8b9dfb1be00cd22b5fc8a79f6b86823..82b578b48956d0bddb02517b5b0e6b58c8061b7a 100644 (file)
@@ -5,6 +5,7 @@
  * Install, update and uninstall functions for the Comment module.
  */
 
+use Drupal\comment\Entity\Comment;
 use Drupal\Core\Entity\EntityTypeInterface;
 use Drupal\Core\StringTranslation\PluralTranslatableMarkup;
 use Drupal\Core\StringTranslation\TranslatableMarkup;
@@ -195,3 +196,14 @@ function comment_update_8400() {
   $entity_definition_update_manager = \Drupal::service('entity.definition_update_manager');
   $entity_definition_update_manager->updateFieldStorageDefinition($entity_definition_update_manager->getFieldStorageDefinition('status', 'comment'));
 }
+
+/**
+ * Configure the comment hostname base field to use a default value callback.
+ */
+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);
+}