EntityTestMulLangcodeKey.php 1.74 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
<?php

/**
 * @file
 * Contains \Drupal\entity_test\Entity\EntityTestMul.
 */

namespace Drupal\entity_test\Entity;

use Drupal\Core\Entity\EntityTypeInterface;

/**
 * Defines a test entity class using a custom langcode entity key.
 *
 * @ContentEntityType(
 *   id = "entity_test_mul_langcode_key",
 *   label = @Translation("Test entity - data table - langcode key"),
 *   handlers = {
 *     "view_builder" = "Drupal\entity_test\EntityTestViewBuilder",
 *     "access" = "Drupal\entity_test\EntityTestAccessControlHandler",
 *     "form" = {
 *       "default" = "Drupal\entity_test\EntityTestForm",
 *       "delete" = "Drupal\entity_test\EntityTestDeleteForm"
 *     },
 *     "translation" = "Drupal\content_translation\ContentTranslationHandler",
 *     "views_data" = "Drupal\views\EntityViewsData"
 *   },
 *   base_table = "entity_test_mul_langcode_key",
 *   data_table = "entity_test_mul_langcode_key_field_data",
 *   translatable = TRUE,
 *   entity_keys = {
 *     "id" = "id",
 *     "uuid" = "uuid",
 *     "bundle" = "type",
 *     "label" = "name",
 *     "langcode" = "custom_langcode_key",
 *   },
 *   links = {
 *     "canonical" = "entity.entity_test_mul_langcode_key.edit_form",
 *     "edit-form" = "entity.entity_test_mul_langcode_key.edit_form",
 *     "delete-form" = "entity.entity_test_mul_langcode_key.delete_form",
 *   },
 *   field_ui_base_route = "entity.entity_test_mul_langcode_key.admin_form",
 * )
 */
class EntityTestMulLangcodeKey extends EntityTest {

  /**
   * {@inheritdoc}
   */
  public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    $fields = parent::baseFieldDefinitions($entity_type);
    $fields['custom_langcode_key'] = $fields['langcode'];
    unset($fields['langcode']);
    return $fields;
  }

}