class EntityTestCompositeConstraint

Same name in this branch
  1. 9 core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/EntityTestCompositeConstraint.php \Drupal\entity_test\Plugin\Validation\Constraint\EntityTestCompositeConstraint
Same name and namespace in other branches
  1. 11.x core/modules/system/tests/modules/entity_test/src/Entity/EntityTestCompositeConstraint.php \Drupal\entity_test\Entity\EntityTestCompositeConstraint
  2. 11.x core/modules/system/tests/modules/entity_test/src/Plugin/Validation/Constraint/EntityTestCompositeConstraint.php \Drupal\entity_test\Plugin\Validation\Constraint\EntityTestCompositeConstraint

Defines a test class for testing composite constraints.

Plugin annotation


@ContentEntityType(
  id = "entity_test_composite_constraint",
  label = @Translation("Test entity constraints with composite constraint"),
  entity_keys = {
    "id" = "id",
    "uuid" = "uuid",
    "bundle" = "type",
    "label" = "name"
  },
  handlers = {
    "form" = {
      "default" = "Drupal\entity_test\EntityTestForm"
    }
  },
  base_table = "entity_test_composite_constraint",
  persistent_cache = FALSE,
  constraints = {
    "EntityTestComposite" = {},
    "EntityTestEntityLevel" = {},
  }
)

Hierarchy

Expanded class hierarchy of EntityTestCompositeConstraint

1 file declares its use of EntityTestCompositeConstraint
FieldWidgetConstraintValidatorTest.php in core/tests/Drupal/KernelTests/Core/Entity/FieldWidgetConstraintValidatorTest.php

File

core/modules/system/tests/modules/entity_test/src/Entity/EntityTestCompositeConstraint.php, line 32

Namespace

Drupal\entity_test\Entity
View source
class EntityTestCompositeConstraint extends EntityTest {
  
  /**
   * {@inheritdoc}
   */
  public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    $fields = parent::baseFieldDefinitions($entity_type);
    $fields['name']->setDisplayOptions('form', [
      'type' => 'string',
      'weight' => 0,
    ]);
    $fields['type']->setDisplayOptions('form', [
      'type' => 'entity_reference_autocomplete',
      'weight' => 0,
    ]);
    return $fields;
  }

}

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