class ConfigExistsConstraint

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Config/Plugin/Validation/Constraint/ConfigExistsConstraint.php \Drupal\Core\Config\Plugin\Validation\Constraint\ConfigExistsConstraint
  2. 10 core/lib/Drupal/Core/Config/Plugin/Validation/Constraint/ConfigExistsConstraint.php \Drupal\Core\Config\Plugin\Validation\Constraint\ConfigExistsConstraint

Checks that the value is the name of an existing config object.

Attributes

#[Constraint(id: 'ConfigExists', label: new TranslatableMarkup('Config exists', [], [ 'context' => 'Validation', ]))]

Hierarchy

  • class \Drupal\Core\Config\Plugin\Validation\Constraint\ConfigExistsConstraint extends \Symfony\Component\Validator\Constraint

Expanded class hierarchy of ConfigExistsConstraint

1 file declares its use of ConfigExistsConstraint
ConfigExistsConstraintValidatorTest.php in core/tests/Drupal/KernelTests/Core/Config/ConfigExistsConstraintValidatorTest.php

File

core/lib/Drupal/Core/Config/Plugin/Validation/Constraint/ConfigExistsConstraint.php, line 14

Namespace

Drupal\Core\Config\Plugin\Validation\Constraint
View source
class ConfigExistsConstraint extends SymfonyConstraint {
  
  /**
   * Constructs a ConfigExistsConstraint object.
   *
   * @param string $prefix
   *   Optional prefix, to be specified when this contains a config entity ID.
   *   Every config entity type can have multiple instances, all with unique IDs
   *   but the same config prefix. When config refers to a config entity,
   *   typically only the ID is stored, not the prefix.
   * @param string $message
   *   The error message if the config does not exist.
   * @param array|null $groups
   *   The groups that the constraint belongs to.
   * @param mixed|null $payload
   *   Domain-specific data attached to a constraint.
   */
  public function __construct(public string $prefix = '', public string $message = "The '@name' config does not exist.", ?array $groups = NULL, mixed $payload = NULL) {
    parent::__construct(groups: $groups, payload: $payload);
  }

}

Members

Title Sort descending Modifiers Object type Summary
ConfigExistsConstraint::__construct public function Constructs a ConfigExistsConstraint object.

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