public function LinkWidget::flagErrors in Drupal 10
Same name and namespace in other branches
- 8 core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php \Drupal\link\Plugin\Field\FieldWidget\LinkWidget::flagErrors()
- 9 core/modules/link/src/Plugin/Field/FieldWidget/LinkWidget.php \Drupal\link\Plugin\Field\FieldWidget\LinkWidget::flagErrors()
Override the '%uri' message parameter, to ensure that 'internal:' URIs show a validation error message that doesn't mention that scheme.
Overrides WidgetBase::flagErrors
File
- core/
modules/ link/ src/ Plugin/ Field/ FieldWidget/ LinkWidget.php, line 428
Class
- LinkWidget
- Plugin implementation of the 'link' widget.
Namespace
Drupal\link\Plugin\Field\FieldWidgetCode
public function flagErrors(FieldItemListInterface $items, ConstraintViolationListInterface $violations, array $form, FormStateInterface $form_state) {
/** @var \Symfony\Component\Validator\ConstraintViolationInterface $violation */
foreach ($violations as $offset => $violation) {
$parameters = $violation
->getParameters();
if (isset($parameters['@uri'])) {
$parameters['@uri'] = static::getUriAsDisplayableString($parameters['@uri']);
$violations
->set($offset, new ConstraintViolation($this
->t($violation
->getMessageTemplate(), $parameters), $violation
->getMessageTemplate(), $parameters, $violation
->getRoot(), $violation
->getPropertyPath(), $violation
->getInvalidValue(), $violation
->getPlural(), $violation
->getCode()));
}
}
parent::flagErrors($items, $violations, $form, $form_state);
}