class LinkTypeConstraint

Same name and namespace in other branches
  1. 10 core/modules/link/src/Plugin/Validation/Constraint/LinkTypeConstraint.php \Drupal\link\Plugin\Validation\Constraint\LinkTypeConstraint
  2. 9 core/modules/link/src/Plugin/Validation/Constraint/LinkTypeConstraint.php \Drupal\link\Plugin\Validation\Constraint\LinkTypeConstraint
  3. 8.9.x core/modules/link/src/Plugin/Validation/Constraint/LinkTypeConstraint.php \Drupal\link\Plugin\Validation\Constraint\LinkTypeConstraint
  4. main core/modules/link/src/Plugin/Validation/Constraint/LinkTypeConstraint.php \Drupal\link\Plugin\Validation\Constraint\LinkTypeConstraint

Validation constraint for links receiving data allowed by its settings.

Attributes

#[Constraint(id: 'LinkType', label: new TranslatableMarkup('Link data valid for link type.', [], [ 'context' => 'Validation', ]))]

Hierarchy

  • class \Drupal\link\Plugin\Validation\Constraint\LinkTypeConstraint extends \Symfony\Component\Validator\Constraint

Expanded class hierarchy of LinkTypeConstraint

1 file declares its use of LinkTypeConstraint
LinkTypeConstraintValidatorTest.php in core/modules/link/tests/src/Unit/Plugin/Validation/Constraint/LinkTypeConstraintValidatorTest.php

File

core/modules/link/src/Plugin/Validation/Constraint/LinkTypeConstraint.php, line 13

Namespace

Drupal\link\Plugin\Validation\Constraint
View source
class LinkTypeConstraint extends SymfonyConstraint {
  public function __construct(mixed $options = NULL, public string $message = '', public string $invalidMessage = "The URL '@uri' is invalid.", public string $onlyInternalMessage = "The URL '@uri' is external, but the @field-label field only supports internal paths.", public string $onlyExternalMessage = "The URL '@uri' is internal, but the @field-label field only supports external URLs.", ?array $groups = NULL, mixed $payload = NULL) {
    if ($message !== '') {
      @trigger_error('Passing the $message argument to ' . __METHOD__ . '() is deprecated in drupal:11.5.0 and is removed from drupal:12.0.0. Use the $invalidMessage argument instead. See https://www.drupal.org/node/3614626', E_USER_DEPRECATED);
      if ($this->invalidMessage === "The URL '@uri' doesn't exist.") {
        $this->invalidMessage = $message;
      }
    }
    parent::__construct($options, $groups, $payload);
  }

}

Members

Title Sort descending Modifiers Object type Summary
LinkTypeConstraint::__construct public function #[HasNamedArguments]

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.