Version 1
[yaffs-website] / web / core / modules / system / tests / modules / entity_test / src / Entity / EntityTestCompositeConstraint.php
diff --git a/web/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestCompositeConstraint.php b/web/core/modules/system/tests/modules/entity_test/src/Entity/EntityTestCompositeConstraint.php
new file mode 100644 (file)
index 0000000..bd28b34
--- /dev/null
@@ -0,0 +1,52 @@
+<?php
+
+namespace Drupal\entity_test\Entity;
+use Drupal\Core\Entity\EntityTypeInterface;
+
+/**
+ * Defines a test class for testing composite constraints.
+ *
+ * @ContentEntityType(
+ *   id = "entity_test_composite_constraint",
+ *   label = @Translation("Test entity constraints with composite constraint"),
+ *   entity_keys = {
+ *     "id" = "id",
+ *     "uuid" = "uuid",
+ *     "bundle" = "type",
+ *     "label" = "name"
+ *   },
+ *   handlers = {
+ *     "form" = {
+ *       "default" = "Drupal\entity_test\EntityTestForm"
+ *     }
+ *   },
+ *   base_table = "entity_test_composite_constraint",
+ *   persistent_cache = FALSE,
+ *   constraints = {
+ *     "EntityTestComposite" = {},
+ *     "EntityTestEntityLevel" = {},
+ *   }
+ * )
+ */
+class EntityTestCompositeConstraint extends EntityTest {
+
+  /**
+   * {@inheritdoc}
+   */
+  public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
+    $fields = parent::baseFieldDefinitions($entity_type);
+
+    $fields['name']->setDisplayOptions('form', [
+      'type' => 'string',
+      'weight' => 0,
+    ]);
+
+    $fields['type']->setDisplayOptions('form', [
+      'type' => 'entity_reference_autocomplete',
+      'weight' => 0,
+    ]);
+
+    return $fields;
+  }
+
+}