public function TextWithSummaryItem::getConstraints in Drupal 9
Same name and namespace in other branches
- 8 core/modules/text/src/Plugin/Field/FieldType/TextWithSummaryItem.php \Drupal\text\Plugin\Field\FieldType\TextWithSummaryItem::getConstraints()
Gets a list of validation constraints.
Return value
array Array of constraints, each being an instance of \Symfony\Component\Validator\Constraint.
Overrides TypedData::getConstraints
File
- core/
modules/ text/ src/ Plugin/ Field/ FieldType/ TextWithSummaryItem.php, line 112
Class
- TextWithSummaryItem
- Plugin implementation of the 'text_with_summary' field type.
Namespace
Drupal\text\Plugin\Field\FieldTypeCode
public function getConstraints() {
$constraints = parent::getConstraints();
if ($this
->getSetting('required_summary')) {
$manager = $this
->getTypedDataManager()
->getValidationConstraintManager();
$constraints[] = $manager
->create('ComplexData', [
'summary' => [
'NotNull' => [
'message' => $this
->t('The summary field is required for @name', [
'@name' => $this
->getFieldDefinition()
->getLabel(),
]),
],
],
]);
}
return $constraints;
}