Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / system / tests / modules / entity_test / src / Entity / EntityTestCompositeConstraint.php
1 <?php
2
3 namespace Drupal\entity_test\Entity;
4
5 use Drupal\Core\Entity\EntityTypeInterface;
6
7 /**
8  * Defines a test class for testing composite constraints.
9  *
10  * @ContentEntityType(
11  *   id = "entity_test_composite_constraint",
12  *   label = @Translation("Test entity constraints with composite constraint"),
13  *   entity_keys = {
14  *     "id" = "id",
15  *     "uuid" = "uuid",
16  *     "bundle" = "type",
17  *     "label" = "name"
18  *   },
19  *   handlers = {
20  *     "form" = {
21  *       "default" = "Drupal\entity_test\EntityTestForm"
22  *     }
23  *   },
24  *   base_table = "entity_test_composite_constraint",
25  *   persistent_cache = FALSE,
26  *   constraints = {
27  *     "EntityTestComposite" = {},
28  *     "EntityTestEntityLevel" = {},
29  *   }
30  * )
31  */
32 class EntityTestCompositeConstraint extends EntityTest {
33
34   /**
35    * {@inheritdoc}
36    */
37   public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
38     $fields = parent::baseFieldDefinitions($entity_type);
39
40     $fields['name']->setDisplayOptions('form', [
41       'type' => 'string',
42       'weight' => 0,
43     ]);
44
45     $fields['type']->setDisplayOptions('form', [
46       'type' => 'entity_reference_autocomplete',
47       'weight' => 0,
48     ]);
49
50     return $fields;
51   }
52
53 }