public function MappedTerms::getConstraints in Search API Field Map 8.3
Same name and namespace in other branches
- 8 src/Plugin/Field/FieldType/MappedTerms.php \Drupal\search_api_field_map\Plugin\Field\FieldType\MappedTerms::getConstraints()
- 8.2 src/Plugin/Field/FieldType/MappedTerms.php \Drupal\search_api_field_map\Plugin\Field\FieldType\MappedTerms::getConstraints()
- 4.x src/Plugin/Field/FieldType/MappedTerms.php \Drupal\search_api_field_map\Plugin\Field\FieldType\MappedTerms::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
- src/
Plugin/ Field/ FieldType/ MappedTerms.php, line 58 - Contains \Drupal\search_api_field_map\Plugin\field\field_type\MappedTerms.
Class
- MappedTerms
- Plugin implementation of the 'mapped_terms' field type.
Namespace
Drupal\search_api_field_map\Plugin\Field\FieldTypeCode
public function getConstraints() {
$constraints = parent::getConstraints();
if ($max_length = $this
->getSetting('max_length')) {
$constraint_manager = \Drupal::typedDataManager()
->getValidationConstraintManager();
$constraints[] = $constraint_manager
->create('ComplexData', [
'value' => [
'Length' => [
'max' => static::MAPPED_TERMS_MAXLENGTH,
'maxMessage' => t('%name: may not be longer than @max characters.', [
'%name' => $this
->getFieldDefinition()
->getLabel(),
'@max' => static::MAPPED_TERMS_MAXLENGTH,
]),
],
],
]);
}
return $constraints;
}