Added Entity and Entity Reference Revisions which got dropped somewhere along the...
[yaffs-website] / web / core / modules / comment / comment.install
index 47241c281ddcab774860ad22689403184dd95e29..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;
@@ -184,3 +185,25 @@ function comment_update_8301() {
   $entity_type->set('entity_keys', $keys);
   $definition_update_manager->updateEntityType($entity_type);
 }
+
+/**
+ * Update the status field.
+ */
+function comment_update_8400() {
+  // The status field was promoted to an entity key in comment_update_8301(),
+  // which makes it NOT NULL in the default SQL storage, which means its storage
+  // definition needs to be updated as well.
+  $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);
+}