EntityTestRev.php 1.79 KB
Newer Older
1 2 3 4
<?php

/**
 * @file
5
 * Contains \Drupal\entity_test\Entity\EntityTestRev.
6 7
 */

8
namespace Drupal\entity_test\Entity;
9

10
use Drupal\Core\Entity\EntityTypeInterface;
11
use Drupal\Core\Field\BaseFieldDefinition;
12
use Drupal\entity_test\Entity\EntityTest;
13 14 15 16

/**
 * Defines the test entity class.
 *
17
 * @ContentEntityType(
18 19
 *   id = "entity_test_rev",
 *   label = @Translation("Test entity - revisions"),
20
 *   handlers = {
21
 *     "access" = "Drupal\entity_test\EntityTestAccessControlHandler",
22
 *     "form" = {
23 24
 *       "default" = "Drupal\entity_test\EntityTestForm",
 *       "delete" = "Drupal\entity_test\EntityTestDeleteForm"
25
 *     },
26 27
 *     "translation" = "Drupal\content_translation\ContentTranslationHandler",
 *     "views_data" = "Drupal\views\EntityViewsData"
28 29 30 31 32 33 34
 *   },
 *   base_table = "entity_test_rev",
 *   revision_table = "entity_test_rev_revision",
 *   entity_keys = {
 *     "id" = "id",
 *     "uuid" = "uuid",
 *     "revision" = "revision_id",
35 36
 *     "bundle" = "type",
 *     "label" = "name",
37
 *   },
38
 *   links = {
39 40 41
 *     "canonical" = "entity.entity_test_rev.edit_form",
 *     "delete-form" = "entity.entity_test_rev.delete_form",
 *     "edit-form" = "entity.entity_test_rev.edit_form"
42
 *   }
43 44 45 46
 * )
 */
class EntityTestRev extends EntityTest {

47 48 49
  /**
   * {@inheritdoc}
   */
50
  public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
51
    $fields = parent::baseFieldDefinitions($entity_type);
52

53
    $fields['revision_id'] = BaseFieldDefinition::create('integer')
54 55
      ->setLabel(t('Revision ID'))
      ->setDescription(t('The version id of the test entity.'))
56 57
      ->setReadOnly(TRUE)
      ->setSetting('unsigned', TRUE);
58

59 60 61 62
    $fields['langcode']->setRevisionable(TRUE);
    $fields['name']->setRevisionable(TRUE);
    $fields['user_id']->setRevisionable(TRUE);

63 64
    return $fields;
  }
65

66
}