class ExtensionExistsConstraint

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

Checks that the value is the name of an installed extension.

Attributes

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

Hierarchy

  • class \Drupal\Core\Extension\Plugin\Validation\Constraint\ExtensionExistsConstraint extends \Symfony\Component\Validator\Constraint

Expanded class hierarchy of ExtensionExistsConstraint

1 file declares its use of ExtensionExistsConstraint
ExtensionExistsConstraintValidatorTest.php in core/tests/Drupal/KernelTests/Core/Extension/ExtensionExistsConstraintValidatorTest.php

File

core/lib/Drupal/Core/Extension/Plugin/Validation/Constraint/ExtensionExistsConstraint.php, line 14

Namespace

Drupal\Core\Extension\Plugin\Validation\Constraint
View source
class ExtensionExistsConstraint extends SymfonyConstraint {
  
  /**
   * Constructs an ExtensionExistsConstraint.
   *
   * @param string $type
   *   The type of extension to look for. Can be 'module' or 'theme'.
   * @param string $moduleMessage
   *   Error message if module is not installed.
   * @param string $themeMessage
   *   Error message if theme is not installed.
   * @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 $type, public string $moduleMessage = "Module '@name' is not installed.", public string $themeMessage = "Theme '@name' is not installed.", ?array $groups = NULL, mixed $payload = NULL) {
    parent::__construct(groups: $groups, payload: $payload);
  }

}

Members

Title Sort descending Modifiers Object type Summary
ExtensionExistsConstraint::__construct public function Constructs an ExtensionExistsConstraint.

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