EntityTestConstraints.php

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

Namespace

Drupal\entity_test\Entity

File

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

View source
<?php

namespace Drupal\entity_test\Entity;

use Drupal\Core\Entity\EntityChangedTrait;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Entity\EntityChangedInterface;
use Drupal\Core\Field\BaseFieldDefinition;

/**
 * Defines a test class for testing the definition of entity level constraints.
 *
 * @ContentEntityType(
 *   id = "entity_test_constraints",
 *   label = @Translation("Test entity constraints"),
 *   entity_keys = {
 *     "id" = "id",
 *     "uuid" = "uuid",
 *     "bundle" = "type",
 *     "label" = "name"
 *   },
 *   base_table = "entity_test_constraints",
 *   persistent_cache = FALSE,
 *   constraints = {
 *     "NotNull" = {}
 *   }
 * )
 */
class EntityTestConstraints extends EntityTest implements EntityChangedInterface {
    use EntityChangedTrait;
    
    /**
     * {@inheritdoc}
     */
    public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
        $fields = parent::baseFieldDefinitions($entity_type);
        $fields['changed'] = BaseFieldDefinition::create('changed')->setLabel(t('Changed'));
        return $fields;
    }

}

Classes

Title Deprecated Summary
EntityTestConstraints Defines a test class for testing the definition of entity level constraints.

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