class EntityTestDefaultValue

Same name and namespace in other branches
  1. 11.x core/modules/system/tests/modules/entity_test/src/Entity/EntityTestDefaultValue.php \Drupal\entity_test\Entity\EntityTestDefaultValue

Defines a test entity class for testing default values.

Plugin annotation


@ContentEntityType(
  id = "entity_test_default_value",
  label = @Translation("Test entity for default values"),
  base_table = "entity_test_default_value",
  entity_keys = {
    "id" = "id",
    "uuid" = "uuid",
    "bundle" = "type",
    "langcode" = "langcode"
  }
)

Hierarchy

Expanded class hierarchy of EntityTestDefaultValue

File

core/modules/system/tests/modules/entity_test/src/Entity/EntityTestDefaultValue.php, line 23

Namespace

Drupal\entity_test\Entity
View source
class EntityTestDefaultValue extends EntityTest {
  
  /**
   * {@inheritdoc}
   */
  public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    $fields = parent::baseFieldDefinitions($entity_type);
    $fields['description'] = BaseFieldDefinition::create('shape')->setLabel(t('Some custom description'))
      ->setDefaultValueCallback('entity_test_field_default_value');
    return $fields;
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.