EntityTestWithBundle.php

Same filename in other branches
  1. 9 core/modules/system/tests/modules/entity_test/src/Entity/EntityTestWithBundle.php
  2. 8.9.x core/modules/system/tests/modules/entity_test/src/Entity/EntityTestWithBundle.php
  3. 10 core/modules/system/tests/modules/entity_test/src/Entity/EntityTestWithBundle.php

Namespace

Drupal\entity_test\Entity

File

core/modules/system/tests/modules/entity_test/src/Entity/EntityTestWithBundle.php

View source
<?php

declare (strict_types=1);
namespace Drupal\entity_test\Entity;

use Drupal\Core\Entity\Attribute\ContentEntityType;
use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Entity\EntityDeleteForm;
use Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\Core\Entity\ContentEntityBase;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\entity_test\EntityTestAccessControlHandler;
use Drupal\entity_test\EntityTestListBuilder;
use Drupal\entity_test\EntityTestViewBuilder as TestViewBuilder;

/**
 * Defines the Test entity with bundle entity class.
 */
class EntityTestWithBundle 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)
            ->setDisplayConfigurable('view', TRUE)
            ->setDisplayOptions('view', [
            'label' => 'hidden',
            'type' => 'string',
            'weight' => -5,
        ])
            ->setDisplayOptions('form', [
            'type' => 'string_textfield',
            'weight' => -5,
        ]);
        return $fields;
    }

}

Classes

Title Deprecated Summary
EntityTestWithBundle Defines the Test entity with bundle entity class.

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