class EntityHasFieldConstraint in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityHasFieldConstraint.php \Drupal\Core\Entity\Plugin\Validation\Constraint\EntityHasFieldConstraint
- 9 core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityHasFieldConstraint.php \Drupal\Core\Entity\Plugin\Validation\Constraint\EntityHasFieldConstraint
Checks if a value is an entity that has a specific field.
Plugin annotation
@Constraint(
id = "EntityHasField",
label = @Translation("Entity has field", context = "Validation"),
type = { "entity" },
)
Hierarchy
- class \Drupal\Core\Entity\Plugin\Validation\Constraint\EntityHasFieldConstraint extends \Symfony\Component\Validator\Constraint
Expanded class hierarchy of EntityHasFieldConstraint
File
- core/
lib/ Drupal/ Core/ Entity/ Plugin/ Validation/ Constraint/ EntityHasFieldConstraint.php, line 16
Namespace
Drupal\Core\Entity\Plugin\Validation\ConstraintView source
class EntityHasFieldConstraint extends Constraint {
/**
* The default violation message.
*
* @var string
*/
public $message = 'The entity must have the %field_name field.';
/**
* The violation message for non-fieldable entities.
*
* @var string
*/
public $notFieldableMessage = 'The entity does not support fields.';
/**
* The field name option.
*
* @var string
*/
public $field_name;
/**
* {@inheritdoc}
*/
public function getDefaultOption() {
return 'field_name';
}
/**
* {@inheritdoc}
*/
public function getRequiredOptions() {
return (array) $this
->getDefaultOption();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityHasFieldConstraint:: |
public | property | The field name option. | |
EntityHasFieldConstraint:: |
public | property | The default violation message. | |
EntityHasFieldConstraint:: |
public | property | The violation message for non-fieldable entities. | |
EntityHasFieldConstraint:: |
public | function | ||
EntityHasFieldConstraint:: |
public | function |