class EntityTypeConstraint

Checks if a value is a valid entity type.

@todo: Move this below the entity core component.

Plugin annotation


@Plugin(
  id = "EntityType",
  label = @Translation("Entity type", context = "Validation"),
  type = "entity"
)

Hierarchy

Expanded class hierarchy of EntityTypeConstraint

File

drupal/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/EntityTypeConstraint.php, line 26
Contains \Drupal\Core\Validation\Constraint\EntityTypeConstraint.

Namespace

Drupal\Core\Validation\Plugin\Validation\Constraint
View source
class EntityTypeConstraint extends Constraint {

  /**
   * The default violation message.
   *
   * @var string
   */
  public $message = 'The entity must be of type %type.';

  /**
   * The entity type option.
   *
   * @var string
   */
  public $type;

  /**
   * Overrides Constraint::getDefaultOption().
   */
  public function getDefaultOption() {
    return 'type';
  }

  /**
   * Overrides Constraint::getRequiredOptions().
   */
  public function getRequiredOptions() {
    return array(
      'type',
    );
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Constraint::$groups public property
Constraint::addImplicitGroupName public function Adds the given group if this constraint is in the Default group
Constraint::CLASS_CONSTRAINT constant Marks a constraint that can be put onto classes
Constraint::DEFAULT_GROUP constant The name of the group given to all constraints with no explicit group
Constraint::getTargets public function Returns whether the constraint can be put onto classes, properties or both 7
Constraint::PROPERTY_CONSTRAINT constant Marks a constraint that can be put onto properties
Constraint::validatedBy public function Returns the name of the class that validates this constraint 2
Constraint::__construct public function Initializes the constraint with options. 10
Constraint::__set public function Unsupported operation.
EntityTypeConstraint::$message public property The default violation message.
EntityTypeConstraint::$type public property The entity type option.
EntityTypeConstraint::getDefaultOption public function Overrides Constraint::getDefaultOption(). Overrides Constraint::getDefaultOption
EntityTypeConstraint::getRequiredOptions public function Overrides Constraint::getRequiredOptions(). Overrides Constraint::getRequiredOptions