Version 1
[yaffs-website] / web / core / modules / system / tests / modules / entity_test / src / Entity / EntityTestUpdate.php
diff --git a/web/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestUpdate.php b/web/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestUpdate.php
new file mode 100644 (file)
index 0000000..6d72f7a
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+
+namespace Drupal\entity_test\Entity;
+
+use Drupal\Core\Entity\EntityTypeInterface;
+
+/**
+ * Defines the test entity class for testing definition updates.
+ *
+ * This entity type starts out non-revisionable by lacking a "revision_id" key,
+ * but during an update test, can be made revisionable by adding that key.
+ *
+ * @ContentEntityType(
+ *   id = "entity_test_update",
+ *   label = @Translation("Test entity update"),
+ *   handlers = {
+ *     "storage_schema" = "Drupal\entity_test\EntityTestStorageSchema"
+ *   },
+ *   base_table = "entity_test_update",
+ *   revision_table = "entity_test_update_revision",
+ *   persistent_cache = FALSE,
+ *   entity_keys = {
+ *     "id" = "id",
+ *     "uuid" = "uuid",
+ *     "bundle" = "type",
+ *     "label" = "name",
+ *     "langcode" = "langcode",
+ *   }
+ * )
+ */
+class EntityTestUpdate extends EntityTestRev {
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
+    $fields = parent::baseFieldDefinitions($entity_type);
+    $fields += \Drupal::state()->get('entity_test_update.additional_base_field_definitions', []);
+    return $fields;
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function bundleFieldDefinitions(EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) {
+    $fields = parent::bundleFieldDefinitions($entity_type, $bundle, $base_field_definitions);
+    $fields += \Drupal::state()->get('entity_test_update.additional_bundle_field_definitions.' . $bundle, []);
+    return $fields;
+  }
+
+}