You are here

EntityTestWithoutBundle.php in Inline Entity Form 8

File

tests/modules/inline_entity_form_test/src/Entity/EntityTestWithoutBundle.php
View source
<?php

namespace Drupal\inline_entity_form_test\Entity;

use Drupal\Core\Entity\ContentEntityBase;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;

/**
 * Defines a test entity class without bundles.
 *
 * @ContentEntityType(
 *   id = "entity_test__without_bundle",
 *   label = @Translation("Test entity without bundle"),
 *   base_table = "entity_test__without_bundle",
 *   admin_permission = "administer entity_test__without_bundle content",
 *   entity_keys = {
 *     "id" = "id",
 *     "uuid" = "uuid",
 *     "label" = "name",
 *     "langcode" = "langcode",
 *   },
 *   handlers = {
 *     "route_provider" = {
 *       "html" = "Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider",
 *     },
 *   },
 *   links = {
 *     "canonical" = "/entity_test__without_bundle/{entity_test__without_bundle}",
 *   },
 * )
 */
class EntityTestWithoutBundle extends ContentEntityBase {

  /**
   * {@inheritdoc}
   */
  public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    $fields = parent::baseFieldDefinitions($entity_type);
    $fields['name'] = BaseFieldDefinition::create('string')
      ->setLabel(t('Name'))
      ->setDescription(t('The name of the test entity.'))
      ->setTranslatable(TRUE)
      ->setSetting('max_length', 32)
      ->setDisplayOptions('view', [
      'label' => 'hidden',
      'type' => 'string',
      'weight' => -5,
    ])
      ->setDisplayOptions('form', [
      'type' => 'string_textfield',
      'weight' => -5,
    ]);
    return $fields;
  }

}

Classes

Namesort descending Description
EntityTestWithoutBundle Defines a test entity class without bundles.