Added Entity and Entity Reference Revisions which got dropped somewhere along the...
[yaffs-website] / web / modules / contrib / entity_reference_revisions / tests / modules / entity_composite_relationship_test / src / Entity / EntityTestCompositeRelationship.php
1 <?php
2
3 namespace Drupal\entity_composite_relationship_test\Entity;
4
5 use Drupal\Core\Entity\EntityTypeInterface;
6 use Drupal\Core\Field\BaseFieldDefinition;
7 use Drupal\entity_reference_revisions\EntityNeedsSaveInterface;
8 use Drupal\entity_reference_revisions\EntityNeedsSaveTrait;
9 use Drupal\entity_test\Entity\EntityTestMulRev;
10
11 /**
12  * Defines the test entity class.
13  *
14  * @ContentEntityType(
15  *   id = "entity_test_composite",
16  *   label = @Translation("Test entity - composite relationship"),
17  *   base_table = "entity_test_composite",
18  *   revision_table = "entity_test_composite_revision",
19  *   data_table = "entity_test_composite_field_data",
20  *   revision_data_table = "entity_test_composite_field_revision",
21  *   content_translation_ui_skip = TRUE,
22  *   translatable = TRUE,
23  *   entity_revision_parent_type_field = "parent_type",
24  *   entity_revision_parent_id_field = "parent_id",
25  *   entity_revision_parent_field_name_field = "parent_field_name",
26  *   admin_permission = "administer entity_test composite relationship",
27  *   entity_keys = {
28  *     "id" = "id",
29  *     "uuid" = "uuid",
30  *     "revision" = "revision_id",
31  *     "bundle" = "type",
32  *     "label" = "name",
33  *     "langcode" = "langcode",
34  *   }
35  * )
36  */
37 class EntityTestCompositeRelationship extends EntityTestMulRev implements EntityNeedsSaveInterface {
38
39   use EntityNeedsSaveTrait;
40
41   /**
42    * {@inheritdoc}
43    */
44   public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
45     $fields = parent::baseFieldDefinitions($entity_type);
46     $fields['parent_id'] = BaseFieldDefinition::create('string')
47       ->setLabel(t('Parent ID'))
48       ->setDescription(t('The ID of the parent entity of which this entity is referenced.'));
49
50     $fields['parent_type'] = BaseFieldDefinition::create('string')
51       ->setLabel(t('Parent type'))
52       ->setDescription(t('The entity parent type to which this entity is referenced.'));
53
54     $fields['parent_field_name'] = BaseFieldDefinition::create('string')
55       ->setLabel(t('Parent field name'))
56       ->setDescription(t('The entity parent field name to which this entity is referenced.'));
57
58     return $fields;
59   }
60
61 }