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

2 files declare their use of ExtensionExistsConstraint
ConstraintFactoryTest.php in core/tests/Drupal/KernelTests/Core/Validation/ConstraintFactoryTest.php
ExtensionExistsConstraintValidatorTest.php in core/tests/Drupal/KernelTests/Core/Extension/ExtensionExistsConstraintValidatorTest.php

File

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

Namespace

Drupal\Core\Extension\Plugin\Validation\Constraint
View source
class ExtensionExistsConstraint extends SymfonyConstraint {
  
  /**
   * The type of extension to look for. Can be 'module' or 'theme'.
   *
   * @var string
   */
  public string $type;
  public function __construct(mixed $options = NULL, ?string $type = NULL, public string $moduleMessage = "Module '@name' is not installed.", public string $themeMessage = "Theme '@name' is not installed.", ?array $groups = NULL, mixed $payload = NULL) {
    parent::__construct($options, $groups, $payload);
    $this->type = $type ?? $this->type;
  }
  
  /**
   * {@inheritdoc}
   */
  public function getRequiredOptions() : array {
    return [
      'type',
    ];
  }
  
  /**
   * {@inheritdoc}
   */
  public function getDefaultOption() : ?string {
    return 'type';
  }

}

Members

Title Sort descending Modifiers Object type Summary
ExtensionExistsConstraint::$type public property The type of extension to look for. Can be 'module' or 'theme'.
ExtensionExistsConstraint::getDefaultOption public function
ExtensionExistsConstraint::getRequiredOptions public function
ExtensionExistsConstraint::__construct public function #[HasNamedArguments]

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